Android Studio: Can permission inspections be permanently ignored using annotations?
<p>I'm developing an Android library which provides ways to reach into various system services and gather data for analysis. My classes make use of various system service managers (like <code>WifiManager</code>) to gather the data.</p>

<p>I'd <em>like</em> to structure the manifest of my library such that it doesn't grab all the possible permissions that all of these features require. Instead, I'd like to leave it up to the app <em>consuming</em> that library to declare only the permissions that <em>it</em> will need, which might be a smaller subset of what's used by the library.</p>

<p>This actually works in practice, because the manifests all get merged together during the build process, so the app ends up with the permissions it needs to use the features of the library. However, since the <code>&lt;uses-permission&gt;</code> tag isn't <em>in</em> the library's manifest, the code is all lit up with warnings from Android Studio.</p>

<ol>
<li><p><strong>Is there a way to annotate my library code such that the permission check is ignored?</strong>
Of course I can simply turn off the "Constant and Resource Type Mismatches" inspection in <em>my</em> Android Studio settings, but that won't help anyone else who's trying to use the library. I tried finding a reference to this inspection in the documentation (so I could kill it with <code>@SuppressWarnings</code> but haven't found it yet.</p></li>
<li><p><strong>Is this even a worthwhile approach?</strong>
…or should I, instead, have the library grab all the permissions it needs, which would force a consumer of the library to <em>turn off</em> the ones it doesn't need using the <code>tools:node="remove"</code> property in <em>its</em> manifest? The problem here is that, as I add features to my library, my library's consumers would repeatedly have to circle back and explicitly remove those new permissions as well. I feel like that's not a great model and I'd rather leave the permission requests to my consumers.</p></li>
</ol>

<p>Consider the following conversations on the subject —</p>

<ul>
<li><a href="https://stackoverflow.com/questions/32520468/android-new-permissions-added-behind-my-back-after-library-updates">Android: New permissions added behind my back after library updates (StackOverflow)</a></li>
<li><a href="https://commonsware.com/blog/2015/06/25/hey-where-did-these-permissions-come-from.html" rel="nofollow noreferrer">Hey, Where Did These Permissions Come From? (CommonsBlog)</a></li>
</ul>