Android studio warning - InnerClass annotations are missing corresponding EnclosingMember annotations

j2emanue picture j2emanue · Mar 27, 2018 · Viewed 11.9k times · Source

I recently upgraded to Android Studio 3.1 and upon building my Kotlin with Java project I got the following warning.

InnerClass annotations are missing corresponding EnclosingMember annotations. Such InnerClass annotations are ignored.

Message {kind=WARNING, text=InnerClass annotations are missing corresponding EnclosingMember annotations. Such InnerClass annotations are ignored., sources=[Unknown source file]}

Here are my Gradle details.

android {
compileSdkVersion 27
//buildToolsVersion '27.0.3'
defaultConfig {
    minSdkVersion 16
    targetSdkVersion 27
    applicationId "org.myapp"
    versionCode generateVersionCode()
  //...
    multiDexEnabled true
}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

It doesn't direct me to where the issue is. How can I locate the offending code?

enter image description here

Answer

dujianchi picture dujianchi · Apr 29, 2018

It may because some annotations be confused, so just add proguard rule:

-keepattributes *Annotation*
-keep @**annotation** class * {*;}

it worked fine to me.