天使漫步IT工作室

升级gradle 3.1 后出现Such InnerClass annotations are ignored.

升级gradle 3.1 和及其对应的jdk后,编译apk的时候出现以下错误:

> Task :app:compileReleaseJavaWithJavac
注: 某些输入文件使用了未经检查或不安全的操作。
注: 有关详细信息, 请使用 -Xlint:unchecked 重新编译。
D8: InnerClass annotations are missing corresponding EnclosingMember annotations. Such InnerClass annotations are ignored.
D8: InnerClass annotations are missing corresponding EnclosingMember annotations. Such InnerClass annotations are ignored.
D8: InnerClass annotations are missing corresponding EnclosingMember annotations. Such InnerClass annotations are ignored.
D8: InnerClass annotations are missing corresponding EnclosingMember annotations. Such InnerClass annotations are ignored.
D8: InnerClass annotations are missing corresponding EnclosingMember annotations. Such InnerClass annotations are ignored.
D8: InnerClass annotations are missing corresponding EnclosingMember annotations. Such InnerClass annotations are ignored.
D8: InnerClass annotations are missing corresponding EnclosingMember annotations. Such InnerClass annotations are ignored.
D8: InnerClass annotations are missing corresponding EnclosingMember annotations. Such InnerClass annotations are ignored.
D8: InnerClass annotations are missing corresponding EnclosingMember annotations. Such InnerClass annotations are ignored.
D8: InnerClass annotations are missing corresponding EnclosingMember annotations. Such InnerClass annotations are ignored.
Warning: The rule `-keep public class *extends java.lang.annotation.Annotation {
  *;
}` uses extends but actually matches implements.

网上查了下,是因为项目中使用了注解插件 比如butterknife   升级3.1之后打包编译  出现以下错误提示  

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

这应该是由于在内部类中使用了注解这样的内部类注解在打包编译的时候是被忽略的。

以下答案来自网友

虽然可以编译完成,并安装到手机可以正常运行;但是对于有些强迫症的我来说 总觉的很不爽  于是找度娘寻找解决方案  由于3.1更新不久 很多国内的小伙伴  没有选择去更新  所以国内相应的帖子也比较少  下面是在一个国外的网站上  别人给出的临时解决方案:

在build.gradle中加入以下代码即可

buildTypes {

    release {

        lintOptions {

            checkReleaseBuilds false

            abortOnError false

        }

    }

}

当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »