Android @Nullable annotation

I want to create

android @Nullable annotation

i check these 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 nobody works in android because RetentionPolicy, ElementType is not valid

How can I create @Nullable annotation in android?

+4
android
source share
2 answers

Include jsr-305 jar file in project libraries. Use @nullable with fields and RoboGuice will stop complaining about null objects.

+2
source share

For Android Studio:

  • Add the following to build.gradle :

     dependencies { ... // For @Nullable/@NonNull compile 'com.android.support:support-annotations:+' } 
  • Go to File / Settings β†’ Project Settings β†’ Inspections and search for β€œnullable”.

    Under constant conditions and exceptions and @ NotNull / @ Nullable problems, click Configure annotations and select Android annotations.

    You can also check Recommend @Nullable annotations ... under Constant conditions and exceptions, or possibly change other parameters.

+2
source share

All Articles