android studio 3.1 Warning: The rule `-keep public class *extends java.lang.annotation.Annotation {

i recently upgraded android studio but im not able to find the source of the following issue reported in android studio 3.1:

Warning: The rule `-keep public class *extends java.lang.annotation.Annotation {

enter image description here

enter image description here

the warning seems to be cut off perhaps and missing information. but it looks like a proguard issue although i am getting this warning when building debug variant. i checked my proguard files and i dont have a line that matches that exactly. i searched the entire project. any ideas on the root cause ?


Solution 1:

As mentioned in the question's comments by @arcone1, @Vincent Mattana & confirmed by @random, the issue is resolved in Android Studio 3.2.

From the issue in Google Issue Tracker:

To clarify, this is a warning, not an error, from R8, which we use to compute the list of classes for the main dex, in legacy multidex variant. It does not affect the output, and it should not cause build nor runtime failures.
I am working on a fix to change this keep rule to "-keep public class * implements java.lang.annotation.Annotation", which is semantically the same, and removes the warning.

So, just ignore it for now or go bleeding edge with Canary (tread at your own risk).

UPDATE: 3.2 is out!

Solution 2:

You are missing a space between the wildcard * and the keyword extends. The warning itself probably does not come from ProGuard but from the builtin shrinker of google.

If you can not find it in your project, then it is most likely a broken rule from a consumer Proguard file included in of the the dependent aar files.

Solution 3:

I got same issue because of "multiDexEnabled true" setting in gradle defaultConfig.

I resolved this issue by adding multidex dependency "implementation 'com.android.support:multidex:1.0.3'"

android {
defaultConfig {
    ...
    multiDexEnabled true
}
...
}

dependencies {
  implementation 'com.android.support:multidex:1.0.3'
}

Reference : https://developer.android.com/studio/build/multidex