Android 工作室警告 - InnerClass 注释缺少相应的 EnclosingMember 注释

Android studio warning - InnerClass annotations are missing corresponding EnclosingMember annotations

我最近升级到 Android Studio 3.1,在使用 Java 项目构建我的 Kotlin 时,我收到了以下警告。

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]}

这是我的 Gradle 详细信息。

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
}

它没有告诉我问题出在哪里。我怎样才能找到违规代码?

为了暂时解决这个问题,我添加了这个:

buildTypes {
    release {
        lintOptions {
            checkReleaseBuilds false
            abortOnError false
        }
    }
}

如果我找到永久修复,将会更新。 This page for configuring JUnit 5 也可能有帮助

可能是因为有些注解混淆了,所以加proguard规则即可:

-keepattributes *注解*
-keep @**annotation** class * {*;}

对我来说效果很好。