11

I'm developing an android app please help me to solve dependency error.

package android.os;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

I've add following dependencies:

dependencies {

    compile group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.0'
    compile 'com.android.support:multidex:1.0.1'
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:support-v4:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.parse:parse-android:1.12.0'
    compile fileTree(include: '*.jar', dir: 'libs')
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.android.support:support-annotations:23.1.1'
}
pratik r
  • 121
  • 1
  • 1
  • 3
  • 1
    did you resolved the issue? none of the provided issue below worked in my case – Kostanos Feb 22 '19 at 18:31
  • A modern take on this question:https://stackoverflow.com/questions/50470474/cannot-resolve-symbol-nonnull-after-android-studio-update – Nitay Oct 12 '19 at 19:16

5 Answers5

16

Add following in your dependencies

compile 'com.android.support:support-annotations:+'

Also, verify this

Go to File -> Setting -> search for "nullable" and verify these settings.

enter image description here

enter image description here

Rohit5k2
  • 17,948
  • 8
  • 45
  • 57
7

Since Google announced at IO17 gradle:3.0, the compile configuration is now deprecated and should be replaced by implementation or api

So prefer

dependencies {
    ...
    implementation 'com.android.support:support-annotations:27.1.1'
    ...
}

or greater version

Kevin ABRIOUX
  • 16,507
  • 12
  • 93
  • 99
5

Add following in your dependencies

dependencies {
    compile 'com.android.support:support-annotations:+'
}
Kanaiya Katarmal
  • 5,974
  • 4
  • 30
  • 56
2

Try:

import android.support.annotation.NonNull;

Also add gradle build as other guys already mentioned:

dependencies {
    compile 'com.android.support:support-annotations:+'
}
Ishaan Javali
  • 1,711
  • 3
  • 13
  • 23
dqshll
  • 121
  • 1
  • 5
1

As of android api 29 ('targetSdkVersion' 29) com.android.support has been moved to 'androidx' library. In your Build.gradle file(app level), dependencies block use...

dependencies{ ...

implementation 'androidx.annotation:annotation:1.1.0' }

And in your .java files use import as follows: import androidx.annotation.NonNull; ...

Again build your project!

userAbhi
  • 695
  • 6
  • 10