senzacionale
senzacionale

Reputation: 20916

android @Nullable annotation

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

Answers (2)

squirrel
squirrel

Reputation: 5488

For Android Studio:

  • Add the following to build.gradle:

    dependencies {
        ...
        // For @Nullable/@NonNull
        compile 'com.android.support:support-annotations:+'
    }
    
  • Go to File / SettingProject SettingsInspections 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

s.d
s.d

Reputation: 29436

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

Upvotes: 2

Related Questions