Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Android Studio warning: "Access can be ..."

After an update of Android Studio I get warnings on fields like:

public int ex1 = 0; int ex2 = 0; 

or methods or nested classes when they are used only in one class or in the package:

"Access can be private" or "Access can be package-only"

This is can be, and I don't want these warnings but I cannot find how I can deactivate them. Any ideas?

like image 658
Zoe stands with Ukraine Avatar asked Dec 20 '16 07:12

Zoe stands with Ukraine


2 Answers

You can also put this annotation on top of your class:

@SuppressWarnings("WeakerAccess") 
like image 102
Muz Avatar answered Sep 29 '22 15:09

Muz


In Android Studio 2.2.1 open Settings-> Editor -> Inspections. Now go to Java->Declaration redundancy->Declaration Access Can be Weaker and uncheck this option.

like image 41
Kush Patel Avatar answered Sep 29 '22 14:09

Kush Patel