升级到Android Studio 2.0后,在Gradle构build过程中发生大量错误

最近,我将Android Studio从1.5版升级到2.0版,但是从那以后我发现错误和警告的数量有所增加。 大部分错误都没有意义。 有人可以帮忙:

AGPBI: {"kind":"error","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","sources":[{}]} AGPBI: {"kind":"error","text":"(org.apache.commons.validator.ValidatorResources$1) that doesn\u0027t come with an","sources":[{}]} AGPBI: {"kind":"error","text":"associated EnclosingMethod attribute. This class was probably produced by a","sources":[{}]} AGPBI: {"kind":"error","text":"compiler that did not target the modern .class file format. The recommended","sources":[{}]} AGPBI: {"kind":"error","text":"solution is to recompile the class from source, using an up-to-date compiler","sources":[{}]} AGPBI: {"kind":"error","text":"and without specifying any \"-target\" type options. The consequence of ignoring","sources":[{}]} AGPBI: {"kind":"error","text":"this warning is that reflective operations on this class will incorrectly","sources":[{}]} AGPBI: {"kind":"error","text":"indicate that it is *not* an inner class.","sources":[{}]} AGPBI: {"kind":"error","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","sources":[{}]} AGPBI: {"kind":"error","text":"(org.apache.commons.digester.ExtendedBaseRules$1) that doesn\u0027t come with an","sources":[{}]} AGPBI: {"kind":"error","text":"associated EnclosingMethod attribute. This class was probably produced by a","sources":[{}]} AGPBI: {"kind":"error","text":"compiler that did not target the modern .class file format. The recommended","sources":[{}]} AGPBI: {"kind":"error","text":"solution is to recompile the class from source, using an up-to-date compiler","sources":[{}]} AGPBI: {"kind":"error","text":"and without specifying any \"-target\" type options. The consequence of ignoring","sources":[{}]} AGPBI: {"kind":"error","text":"this warning is that reflective operations on this class will incorrectly","sources":[{}]} AGPBI: {"kind":"error","text":"indicate that it is *not* an inner class.","sources":[{}]} AGPBI: {"kind":"error","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","sources":[{}]} AGPBI: {"kind":"error","text":"(org.apache.commons.beanutils.BeanMap$5) that doesn\u0027t come with an","sources":[{}]} AGPBI: {"kind":"error","text":"associated EnclosingMethod attribute. This class was probably produced by a","sources":[{}]} AGPBI: {"kind":"error","text":"compiler that did not target the modern .class file format. The recommended","sources":[{}]} AGPBI: {"kind":"error","text":"solution is to recompile the class from source, using an up-to-date compiler","sources":[{}]} AGPBI: {"kind":"error","text":"and without specifying any \"-target\" type options. The consequence of ignoring","sources":[{}]} AGPBI: {"kind":"error","text":"this warning is that reflective operations on this class will incorrectly","sources":[{}]} AGPBI: {"kind":"error","text":"indicate that it is *not* an inner class.","sources":[{}]} AGPBI: {"kind":"error","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","sources":[{}]} AGPBI: {"kind":"error","text":"(org.apache.commons.beanutils.BeanMap$6) that doesn\u0027t come with an","sources":[{}]} AGPBI: {"kind":"error","text":"associated EnclosingMethod attribute. This class was probably produced by a","sources":[{}]} AGPBI: {"kind":"error","text":"compiler that did not target the modern .class file format. The recommended","sources":[{}]} AGPBI: {"kind":"error","text":"solution is to recompile the class from source, using an up-to-date compiler","sources":[{}]} AGPBI: {"kind":"error","text":"and without specifying any \"-target\" type options. The consequence of ignoring","sources":[{}]} AGPBI: {"kind":"error","text":"this warning is that reflective operations on this class will incorrectly","sources":[{}]} AGPBI: {"kind":"error","text":"indicate that it is *not* an inner class.","sources":[{}]} AGPBI: {"kind":"error","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","sources":[{}]} AGPBI: {"kind":"error","text":"(org.apache.commons.beanutils.BeanMap$8) that doesn\u0027t come with an","sources":[{}]} AGPBI: {"kind":"error","text":"associated EnclosingMethod attribute. This class was probably produced by a","sources":[{}]} AGPBI: {"kind":"error","text":"compiler that did not target the modern .class file format. The recommended","sources":[{}]} AGPBI: {"kind":"error","text":"solution is to recompile the class from source, using an up-to-date compiler","sources":[{}]} AGPBI: {"kind":"error","text":"and without specifying any \"-target\" type options. The consequence of ignoring","sources":[{}]} AGPBI: {"kind":"error","text":"this warning is that reflective operations on this class will incorrectly","sources":[{}]} AGPBI: {"kind":"error","text":"indicate that it is *not* an inner class.","sources":[{}]} AGPBI: {"kind":"error","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","sources":[{}]} AGPBI: {"kind":"error","text":"(org.apache.commons.beanutils.BeanMap$9) that doesn\u0027t come with an","sources":[{}]} AGPBI: {"kind":"error","text":"associated EnclosingMethod attribute. This class was probably produced by a","sources":[{}]} AGPBI: {"kind":"error","text":"compiler that did not target the modern .class file format. The recommended","sources":[{}]} AGPBI: {"kind":"error","text":"solution is to recompile the class from source, using an up-to-date compiler","sources":[{}]} AGPBI: {"kind":"error","text":"and without specifying any \"-target\" type options. The consequence of ignoring","sources":[{}]} AGPBI: {"kind":"error","text":"this warning is that reflective operations on this class will incorrectly","sources":[{}]} AGPBI: {"kind":"error","text":"indicate that it is *not* an inner class.","sources":[{}]} AGPBI: {"kind":"error","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","sources":[{}]} AGPBI: {"kind":"error","text":"(org.apache.commons.beanutils.BeanMap$1) that doesn\u0027t come with an","sources":[{}]} AGPBI: {"kind":"error","text":"associated EnclosingMethod attribute. This class was probably produced by a","sources":[{}]} AGPBI: {"kind":"error","text":"compiler that did not target the modern .class file format. The recommended","sources":[{}]} AGPBI: {"kind":"error","text":"solution is to recompile the class from source, using an up-to-date compiler","sources":[{}]} AGPBI: {"kind":"error","text":"and without specifying any \"-target\" type options. The consequence of ignoring","sources":[{}]} AGPBI: {"kind":"error","text":"this warning is that reflective operations on this class will incorrectly","sources":[{}]} AGPBI: {"kind":"error","text":"indicate that it is *not* an inner class.","sources":[{}]} AGPBI: {"kind":"error","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","sources":[{}]} AGPBI: {"kind":"error","text":"(org.apache.commons.beanutils.BeanMap$10) that doesn\u0027t come with an","sources":[{}]} AGPBI: {"kind":"error","text":"associated EnclosingMethod attribute. This class was probably produced by a","sources":[{}]} AGPBI: {"kind":"error","text":"compiler that did not target the modern .class file format. The recommended","sources":[{}]} AGPBI: {"kind":"error","text":"solution is to recompile the class from source, using an up-to-date compiler","sources":[{}]} AGPBI: {"kind":"error","text":"and without specifying any \"-target\" type options. The consequence of ignoring","sources":[{}]} AGPBI: {"kind":"error","text":"this warning is that reflective operations on this class will incorrectly","sources":[{}]} AGPBI: {"kind":"error","text":"indicate that it is *not* an inner class.","sources":[{}]} AGPBI: {"kind":"error","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","sources":[{}]} AGPBI: {"kind":"error","text":"(org.apache.commons.beanutils.BeanMap$11) that doesn\u0027t come with an","sources":[{}]} AGPBI: {"kind":"error","text":"associated EnclosingMethod attribute. This class was probably produced by a","sources":[{}]} AGPBI: {"kind":"error","text":"compiler that did not target the modern .class file format. The recommended","sources":[{}]} AGPBI: {"kind":"error","text":"solution is to recompile the class from source, using an up-to-date compiler","sources":[{}]} AGPBI: {"kind":"error","text":"and without specifying any \"-target\" type options. The consequence of ignoring","sources":[{}]} AGPBI: {"kind":"error","text":"this warning is that reflective operations on this class will incorrectly","sources":[{}]} AGPBI: {"kind":"error","text":"indicate that it is *not* an inner class.","sources":[{}]} AGPBI: {"kind":"error","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","sources":[{}]} AGPBI: {"kind":"error","text":"(org.apache.commons.beanutils.BeanMap$12) that doesn\u0027t come with an","sources":[{}]} AGPBI: {"kind":"error","text":"associated EnclosingMethod attribute. This class was probably produced by a","sources":[{}]} AGPBI: {"kind":"error","text":"compiler that did not target the modern .class file format. The recommended","sources":[{}]} AGPBI: {"kind":"error","text":"solution is to recompile the class from source, using an up-to-date compiler","sources":[{}]} AGPBI: {"kind":"error","text":"and without specifying any \"-target\" type options. The consequence of ignoring","sources":[{}]} AGPBI: {"kind":"error","text":"this warning is that reflective operations on this class will incorrectly","sources":[{}]} AGPBI: {"kind":"error","text":"indicate that it is *not* an inner class.","sources":[{}]} AGPBI: {"kind":"error","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","sources":[{}]} AGPBI: {"kind":"error","text":"(org.apache.commons.beanutils.BeanMap$2) that doesn\u0027t come with an","sources":[{}]} AGPBI: {"kind":"error","text":"associated EnclosingMethod attribute. This class was probably produced by a","sources":[{}]} AGPBI: {"kind":"error","text":"compiler that did not target the modern .class file format. The recommended","sources":[{}]} AGPBI: {"kind":"error","text":"solution is to recompile the class from source, using an up-to-date compiler","sources":[{}]} AGPBI: {"kind":"error","text":"and without specifying any \"-target\" type options. The consequence of ignoring","sources":[{}]} AGPBI: {"kind":"error","text":"this warning is that reflective operations on this class will incorrectly","sources":[{}]} AGPBI: {"kind":"error","text":"indicate that it is *not* an inner class.","sources":[{}]} AGPBI: {"kind":"error","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","sources":[{}]} AGPBI: {"kind":"error","text":"(org.apache.commons.beanutils.BeanMap$3) that doesn\u0027t come with an","sources":[{}]} AGPBI: {"kind":"error","text":"associated EnclosingMethod attribute. This class was probably produced by a","sources":[{}]} AGPBI: {"kind":"error","text":"compiler that did not target the modern .class file format. The recommended","sources":[{}]} AGPBI: {"kind":"error","text":"solution is to recompile the class from source, using an up-to-date compiler","sources":[{}]} AGPBI: {"kind":"error","text":"and without specifying any \"-target\" type options. The consequence of ignoring","sources":[{}]} AGPBI: {"kind":"error","text":"this warning is that reflective operations on this class will incorrectly","sources":[{}]} AGPBI: {"kind":"error","text":"indicate that it is *not* an inner class.","sources":[{}]} AGPBI: {"kind":"error","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","sources":[{}]} AGPBI: {"kind":"error","text":"(org.apache.commons.beanutils.BeanMap$4) that doesn\u0027t come with an","sources":[{}]} AGPBI: {"kind":"error","text":"associated EnclosingMethod attribute. This class was probably produced by a","sources":[{}]} AGPBI: {"kind":"error","text":"compiler that did not target the modern .class file format. The recommended","sources":[{}]} AGPBI: {"kind":"error","text":"solution is to recompile the class from source, using an up-to-date compiler","sources":[{}]} AGPBI: {"kind":"error","text":"and without specifying any \"-target\" type options. The consequence of ignoring","sources":[{}]} AGPBI: {"kind":"error","text":"this warning is that reflective operations on this class will incorrectly","sources":[{}]} AGPBI: {"kind":"error","text":"indicate that it is *not* an inner class.","sources":[{}]} AGPBI: {"kind":"error","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","sources":[{}]} AGPBI: {"kind":"error","text":"(org.apache.commons.beanutils.BeanMap$7) that doesn\u0027t come with an","sources":[{}]} AGPBI: {"kind":"error","text":"associated EnclosingMethod attribute. This class was probably produced by a","sources":[{}]} AGPBI: {"kind":"error","text":"compiler that did not target the modern .class file format. The recommended","sources":[{}]} AGPBI: {"kind":"error","text":"solution is to recompile the class from source, using an up-to-date compiler","sources":[{}]} AGPBI: {"kind":"error","text":"and without specifying any \"-target\" type options. The consequence of ignoring","sources":[{}]} AGPBI: {"kind":"error","text":"this warning is that reflective operations on this class will incorrectly","sources":[{}]} AGPBI: {"kind":"error","text":"indicate that it is *not* an inner class.","sources":[{}]} AGPBI: {"kind":"error","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","sources":[{}]} AGPBI: {"kind":"error","text":"(org.apache.commons.beanutils.BeanUtilsBean$1) that doesn\u0027t come with an","sources":[{}]} AGPBI: {"kind":"error","text":"associated EnclosingMethod attribute. This class was probably produced by a","sources":[{}]} AGPBI: {"kind":"error","text":"compiler that did not target the modern .class file format. The recommended","sources":[{}]} AGPBI: {"kind":"error","text":"solution is to recompile the class from source, using an up-to-date compiler","sources":[{}]} AGPBI: {"kind":"error","text":"and without specifying any \"-target\" type options. The consequence of ignoring","sources":[{}]} AGPBI: {"kind":"error","text":"this warning is that reflective operations on this class will incorrectly","sources":[{}]} AGPBI: {"kind":"error","text":"indicate that it is *not* an inner class.","sources":[{}]} AGPBI: {"kind":"error","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","sources":[{}]} AGPBI: {"kind":"error","text":"(org.apache.commons.beanutils.WrapDynaClass$1) that doesn\u0027t come with an","sources":[{}]} AGPBI: {"kind":"error","text":"associated EnclosingMethod attribute. This class was probably produced by a","sources":[{}]} AGPBI: {"kind":"error","text":"compiler that did not target the modern .class file format. The recommended","sources":[{}]} AGPBI: {"kind":"error","text":"solution is to recompile the class from source, using an up-to-date compiler","sources":[{}]} AGPBI: {"kind":"error","text":"and without specifying any \"-target\" type options. The consequence of ignoring","sources":[{}]} AGPBI: {"kind":"error","text":"this warning is that reflective operations on this class will incorrectly","sources":[{}]} AGPBI: {"kind":"error","text":"indicate that it is *not* an inner class.","sources":[{}]} AGPBI: {"kind":"error","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","sources":[{}]} AGPBI: {"kind":"error","text":"(org.apache.commons.beanutils.WrapDynaClass$2) that doesn\u0027t come with an","sources":[{}]} AGPBI: {"kind":"error","text":"associated EnclosingMethod attribute. This class was probably produced by a","sources":[{}]} AGPBI: {"kind":"error","text":"compiler that did not target the modern .class file format. The recommended","sources":[{}]} AGPBI: {"kind":"error","text":"solution is to recompile the class from source, using an up-to-date compiler","sources":[{}]} AGPBI: {"kind":"error","text":"and without specifying any \"-target\" type options. The consequence of ignoring","sources":[{}]} AGPBI: {"kind":"error","text":"this warning is that reflective operations on this class will incorrectly","sources":[{}]} AGPBI: {"kind":"error","text":"indicate that it is *not* an inner class.","sources":[{}]} AGPBI: {"kind":"error","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","sources":[{}]} AGPBI: {"kind":"error","text":"(org.apache.commons.beanutils.locale.LocaleBeanUtilsBean$1) that doesn\u0027t come with an","sources":[{}]} AGPBI: {"kind":"error","text":"associated EnclosingMethod attribute. This class was probably produced by a","sources":[{}]} AGPBI: {"kind":"error","text":"compiler that did not target the modern .class file format. The recommended","sources":[{}]} AGPBI: {"kind":"error","text":"solution is to recompile the class from source, using an up-to-date compiler","sources":[{}]} AGPBI: {"kind":"error","text":"and without specifying any \"-target\" type options. The consequence of ignoring","sources":[{}]} AGPBI: {"kind":"error","text":"this warning is that reflective operations on this class will incorrectly","sources":[{}]} AGPBI: {"kind":"error","text":"indicate that it is *not* an inner class.","sources":[{}]} 

您可以通过删除Android Studio 1.5创build的.idea文件夹并将该项目导入到Android Studio 2.0中作为Gradle项目来摆脱无意义的警告和错误。 它会自动重新创build.idea文件夹。

-keepattributes EnclosingMethod添加到proguard规则可以抑制这些错误和警告。

为我工作就像一个魅力。

更新:添加-keepattributes EnclosingMethod到proguard规则实际上改变了这些类是如何混淆的。 这保留了可选的属性,这些属性通常是在没有这样的问题的情况下执行代码所必需的。

在我的项目中集成SimpleXML retrofit2转换器后,我收到了几乎相同的消息。 我必须排除一些已经与Android捆绑在一起的库,才能正确构build它。

像这样:

 compile ("com.squareup.retrofit2:converter-simplexml:2.0.2") { exclude group: 'xpp3', module: 'xpp3' exclude group: 'stax', module: 'stax-api' exclude group: 'stax', module: 'stax'} 

上次更新到Android Studio 2.2testing版后,我通过在应用程序build.gradle中更新“buildToolsVersion”以最后可能的版本(从24到24.0.1)解决了问题。

你有没有尝试清理项目和重build? 在build.gradle文件中你有什么版本的Gradle?

 buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.0.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } 

构build通用集合将生成所需的JAR …

我的build.gradle看起来像这样, commons-collections排除, build.gradle一个更新的版本替代(仍然需要从源代码构build,就像消息告诉人们这样做):

 dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') // compile 'commons-collections:commons-collections:3.2.2' // compile 'org.apache.commons:commons-collections4:4.1' compile ('org.apache.velocity:velocity:1.7') { exclude group: 'commons-collections', module: 'commons-collections' } } 

答案应该在这里NewRelic导致构build错误

joinproguard-rules.pro

 -keep class org.apache.commons.beanutils.** { *; } -keep interface org.apache.commons.beanutils.** { *; } -keep enum org.apache.commons.beanutils.** { *; }