Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Intellij @Nullable on "implement methods" when base method is androidx @Nullable

In Android Studio 4.2 beta 1, whenever I implement a method annotated with the androidx version of @Nullable, the IDE is automatically adding the jetbrains @Nullable annotation as well.

This is extremely annoying as it results in code like:

  @Nullable
  @org.jetbrains.annotations.Nullable
  @Override
  public String foo(@Nullable @org.jetbrains.annotations.Nullable String bar) {
    return null;
  }

Any way to prevent this?

like image 322
Android Avatar asked Dec 09 '20 21:12

Android


2 Answers

I ran into this problem and was able to fix it by going to Settings > Editor > Inspections > Probable Bugs > Nullability > @NotNull / @Nullable annotations. Then under Options, click the Configure Annotations button, select androidx.annotation.Nullable and androidx.annotation.NonNull from the respective lists, and press the checkmark to select them as the annotations.

like image 168
jnmorris Avatar answered Oct 24 '22 19:10

jnmorris


As @jnmorris said, follow these steps :

Go to Settings > Editor > Inspections >

enter image description here

enter image description here

Find Java > Probable Bugs > Nullability Problems > @NotNull/@Nullable Problems

enter image description here

enter image description here

Click Configure Annotations button and check these items

enter image description here

like image 37
ucMedia Avatar answered Oct 24 '22 19:10

ucMedia