I'm having a strange issue with inspections in a project that I created only a few days ago in IDEA 2016.3.3, which I upgraded to 2016.3.5 when I encountered this issue. The problem persists in the older project even after invalidating caches and restarting. I cannot reproduce it in a new project created in 2016.3.5.
Both projects have the same minSdkVersion
, targetSdkVersion
, compileSdkVersion
, and buildToolsVersion
. What else could cause this difference in inspection behavior?
I created an identical class in both projects:
public class PermissionWeirdness {
public void foo() {
bar();
baz();
}
@RequiresPermission(Manifest.permission.ACCESS_FINE_LOCATION)
private void bar() {}
@RequiresPermission(Manifest.permission.GET_ACCOUNTS)
private void baz() {}
}
ACCESS_FINE_LOCATION
and GET_ACCOUNTS
are both classified as "dangerous" permissions.foo()
on the calls to bar()
and baz()
.Missing permission required by PermissionWeirdness.bar: android.permission.ACCESS_FINE_LOCATION
ACCESS_FINE_LOCATION
has a completely different message. The tooltip text has literal backticks in it that are interpreted here as code tags:
Call requires permission which may be rejected by user: code should explicitly check to see if permission is available ( with
checkPermission
) or explicitly handle a potentialSecurityException
@RequiresPermission
annotation to foo()
.The difference between the real project and my attempt to reproduce the issue in a sample project was in the manifest. The behavior of the inspection changes for dangerous permissions, but only when they are listed in the manifest. The warning message changes, and @RequiresPermission
no longer cascades.
I originally thought this was a regression of Android Studio bug 177281, but that issue was more general. Not cascading for dangerous permissions may have been intentional, but I've reported it as a bug because the process is killed if the user revokes a permission from a running app.