For my task at work (resolving hardcoded String warnings) I want to not only share @NonNls annotations I add inside our project, but also the external annotations I add via "Add external annotation" in Android Studio in order for my coworkers to not be bombarded with useless warnings like I was starting at this project.
Disabling this type of annotation in general does not fix my problem as I want to keep seeing the useful warnings of this type. In addition, the usual functionality of selecting a folder somewhere in my file system to save the external annotions there in a tree-like structure is also not good enough, because my coworkers would still have to point Android Studio to this folder for every class/method they want to ignore a specific warning for.
I already tried to add a "external_annotations.xml" file in res/xml with e.g. the following content:
<root>
<item name='android.util.Log'>
<annotation name='org.jetbrains.annotations.NonNls' />
</item>
<item name='androidx.fragment.app.DialogFragment void show(androidx.fragment.app.FragmentManager, java.lang.String) 1'>
<annotation name='org.jetbrains.annotations.NonNls' />
</item>
<item name='com.android.volley.VolleyLog'>
<annotation name='org.jetbrains.annotations.NonNls' />
</item>
<item name='com.appsflyer.AppsFlyerLib void logEvent(android.content.Context, java.lang.String, java.util.Map<java.lang.String,java.lang.Object>)'>
<annotation name='org.jetbrains.annotations.NonNls' />
</item>
<item name='com.google.firebase.crashlytics.FirebaseCrashlytics void log(java.lang.String)'>
<annotation name='org.jetbrains.annotations.NonNls' />
</item>
<item name='com.mixpanel.android.mpmetrics.MixpanelAPI void track(java.lang.String)'>
<annotation name='org.jetbrains.annotations.NonNls' />
</item>
</root>
and mentioned it in my build.gradle(:app):
[...]
android {
[...]
lintOptions {
lintConfig file("${project.rootDir}/app/src/main/res/xml/external_annotations.xml")
}
}
[...]
But sadly, this had no effect (even after invalidating caches and restarting).