Reputation: 20916
I want to create
android @Nullable annotation
i check this two links for example
http://findbugs.sourceforge.net/api/edu/umd/cs/findbugs/annotations/Nullable.html http://code.google.com/p/google-guice/wiki/UseNullable
but none works in android because RetentionPolicy, ElementType is not valid
How can i create @Nullable annotation in android?
Upvotes: 4
Views: 4169
Reputation: 5488
For Android Studio:
Add the following to build.gradle:
dependencies {
...
// For @Nullable/@NonNull
compile 'com.android.support:support-annotations:+'
}
Go to File / Setting → Project Settings → Inspections and search for "nullable".
In Constant conditions & exceptions and @NotNull/@Nullable problems, click Configure annotations and select Android's annotations.
You may also want to check Suggest @Nullable annotations… under Constant conditions & exceptions, or possibly tweak other options.
Upvotes: 2