在用log4j更新Android Studio之后,Gradle构build时出错

我更新了Android Studio和SDK后出现这些错误:

Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:(org.apache.log4j.chainsaw.ControlPanel$1) that doesn't come with an Error:associated EnclosingMethod attribute. This class was probably produced by a Error:compiler that did not target the modern .class file format. The recommended Error:solution is to recompile the class from source, using an up-to-date compiler Error:and without specifying any "-target" type options. The consequence of ignoring Error:this warning is that reflective operations on this class will incorrectly Error:indicate that it is *not* an inner class. Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:(org.apache.log4j.chainsaw.ControlPanel$2) that doesn't come with an Error:associated EnclosingMethod attribute. This class was probably produced by a Error:compiler that did not target the modern .class file format. The recommended Error:solution is to recompile the class from source, using an up-to-date compiler Error:and without specifying any "-target" type options. The consequence of ignoring Error:this warning is that reflective operations on this class will incorrectly Error:indicate that it is *not* an inner class. Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:(org.apache.log4j.chainsaw.ControlPanel$3) that doesn't come with an Error:associated EnclosingMethod attribute. This class was probably produced by a Error:compiler that did not target the modern .class file format. The recommended Error:solution is to recompile the class from source, using an up-to-date compiler Error:and without specifying any "-target" type options. The consequence of ignoring Error:this warning is that reflective operations on this class will incorrectly Error:indicate that it is *not* an inner class. Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:(org.apache.log4j.chainsaw.ControlPanel$4) that doesn't come with an Error:associated EnclosingMethod attribute. This class was probably produced by a Error:compiler that did not target the modern .class file format. The recommended Error:solution is to recompile the class from source, using an up-to-date compiler Error:and without specifying any "-target" type options. The consequence of ignoring Error:this warning is that reflective operations on this class will incorrectly Error:indicate that it is *not* an inner class. Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:(org.apache.log4j.chainsaw.ControlPanel$5) that doesn't come with an Error:associated EnclosingMethod attribute. This class was probably produced by a Error:compiler that did not target the modern .class file format. The recommended Error:solution is to recompile the class from source, using an up-to-date compiler Error:and without specifying any "-target" type options. The consequence of ignoring Error:this warning is that reflective operations on this class will incorrectly Error:indicate that it is *not* an inner class. Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:(org.apache.log4j.chainsaw.ControlPanel$6) that doesn't come with an Error:associated EnclosingMethod attribute. This class was probably produced by a Error:compiler that did not target the modern .class file format. The recommended Error:solution is to recompile the class from source, using an up-to-date compiler Error:and without specifying any "-target" type options. The consequence of ignoring Error:this warning is that reflective operations on this class will incorrectly Error:indicate that it is *not* an inner class. Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:(org.apache.log4j.chainsaw.ControlPanel$7) that doesn't come with an Error:associated EnclosingMethod attribute. This class was probably produced by a Error:compiler that did not target the modern .class file format. The recommended Error:solution is to recompile the class from source, using an up-to-date compiler Error:and without specifying any "-target" type options. The consequence of ignoring Error:this warning is that reflective operations on this class will incorrectly Error:indicate that it is *not* an inner class. Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:(org.apache.log4j.chainsaw.Main$1) that doesn't come with an Error:associated EnclosingMethod attribute. This class was probably produced by a Error:compiler that did not target the modern .class file format. The recommended Error:solution is to recompile the class from source, using an up-to-date compiler Error:and without specifying any "-target" type options. The consequence of ignoring Error:this warning is that reflective operations on this class will incorrectly Error:indicate that it is *not* an inner class. Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:(org.apache.log4j.chainsaw.MyTableModel$1) that doesn't come with an Error:associated EnclosingMethod attribute. This class was probably produced by a Error:compiler that did not target the modern .class file format. The recommended Error:solution is to recompile the class from source, using an up-to-date compiler Error:and without specifying any "-target" type options. The consequence of ignoring Error:this warning is that reflective operations on this class will incorrectly Error:indicate that it is *not* an inner class. Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:(org.apache.log4j.lf5.util.LogFileParser$1) that doesn't come with an Error:associated EnclosingMethod attribute. This class was probably produced by a Error:compiler that did not target the modern .class file format. The recommended Error:solution is to recompile the class from source, using an up-to-date compiler Error:and without specifying any "-target" type options. The consequence of ignoring Error:this warning is that reflective operations on this class will incorrectly Error:indicate that it is *not* an inner class. Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:(org.apache.log4j.lf5.viewer.LF5SwingUtils$1) that doesn't come with an Error:associated EnclosingMethod attribute. This class was probably produced by a Error:compiler that did not target the modern .class file format. The recommended Error:solution is to recompile the class from source, using an up-to-date compiler Error:and without specifying any "-target" type options. The consequence of ignoring Error:this warning is that reflective operations on this class will incorrectly Error:indicate that it is *not* an inner class. Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:(org.apache.log4j.lf5.viewer.LogBrokerMonitor$1) that doesn't come with an Error:associated EnclosingMethod attribute. This class was probably produced by a Error:compiler that did not target the modern .class file format. The recommended Error:solution is to recompile the class from source, using an up-to-date compiler Error:and without specifying any "-target" type options. The consequence of ignoring Error:this warning is that reflective operations on this class will incorrectly Error:indicate that it is *not* an inner class. Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:(org.apache.log4j.lf5.viewer.LogBrokerMonitor$10) that doesn't come with an Error:associated EnclosingMethod attribute. This class was probably produced by a Error:compiler that did not target the modern .class file format. The recommended Error:solution is to recompile the class from source, using an up-to-date compiler Error:and without specifying any "-target" type options. The consequence of ignoring Error:this warning is that reflective operations on this class will incorrectly Error:indicate that it is *not* an inner class. Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:(org.apache.log4j.lf5.viewer.LogBrokerMonitor$11) that doesn't come with an Error:associated EnclosingMethod attribute. This class was probably produced by a Error:compiler that did not target the modern .class file format. The recommended Error:solution is to recompile the class from source, using an up-to-date compiler Error:and without specifying any "-target" type options. The consequence of ignoring Error:this warning is that reflective operations on this class will incorrectly Error:indicate that it is *not* an inner class. Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:(org.apache.log4j.lf5.viewer.LogBrokerMonitor$12) that doesn't come with an Error:associated EnclosingMethod attribute. This class was probably produced by a Error:compiler that did not target the modern .class file format. The recommended Error:solution is to recompile the class from source, using an up-to-date compiler Error:and without specifying any "-target" type options. The consequence of ignoring Error:this warning is that reflective operations on this class will incorrectly Error:indicate that it is *not* an inner class. Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:(org.apache.log4j.lf5.viewer.LogBrokerMonitor$13) that doesn't come with an Error:associated EnclosingMethod attribute. This class was probably produced by a Error:compiler that did not target the modern .class file format. The recommended Error:solution is to recompile the class from source, using an up-to-date compiler Error:and without specifying any "-target" type options. The consequence of ignoring Error:this warning is that reflective operations on this class will incorrectly Error:indicate that it is *not* an inner class. Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:(org.apache.log4j.lf5.viewer.LogBrokerMonitor$14) that doesn't come with an Error:associated EnclosingMethod attribute. This class was probably produced by a Error:compiler that did not target the modern .class file format. The recommended Error:solution is to recompile the class from source, using an up-to-date compiler Error:and without specifying any "-target" type options. The consequence of ignoring Error:this warning is that reflective operations on this class will incorrectly Error:indicate that it is *not* an inner class. Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:(org.apache.log4j.lf5.viewer.LogBrokerMonitor$15) that doesn't come with an Error:associated EnclosingMethod attribute. This class was probably produced by a Error:compiler that did not target the modern .class file format. The recommended Error:solution is to recompile the class from source, using an up-to-date compiler Error:and without specifying any "-target" type options. The consequence of ignoring Error:this warning is that reflective operations on this class will incorrectly Error:indicate that it is *not* an inner class. Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:(org.apache.log4j.lf5.viewer.LogBrokerMonitor$16) that doesn't come with an Error:associated EnclosingMethod attribute. This class was probably produced by a Error:compiler that did not target the modern .class file format. The recommended Error:solution is to recompile the class from source, using an up-to-date compiler Error:and without specifying any "-target" type options. The consequence of ignoring Error:this warning is that reflective operations on this class will incorrectly Error:indicate that it is *not* an inner class. Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:(org.apache.log4j.lf5.viewer.LogBrokerMonitor$17) that doesn't come with an Error:associated EnclosingMethod attribute. This class was probably produced by a Error:compiler that did not target the modern .class file format. The recommended Error:solution is to recompile the class from source, using an up-to-date compiler Error:and without specifying any "-target" type options. The consequence of ignoring Error:this warning is that reflective operations on this class will incorrectly Error:indicate that it is *not* an inner class. Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:(org.apache.log4j.lf5.viewer.LogBrokerMonitor$18) that doesn't come with an Error:associated EnclosingMethod attribute. This class was probably produced by a Error:compiler that did not target the modern .class file format. The recommended Error:solution is to recompile the class from source, using an up-to-date compiler Error:and without specifying any "-target" type options. The consequence of ignoring Error:this warning is that reflective operations on this class will incorrectly Error:indicate that it is *not* an inner class. Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:(org.apache.log4j.lf5.viewer.LogBrokerMonitor$19) that doesn't come with an Error:associated EnclosingMethod attribute. This class was probably produced by a Error:compiler that did not target the modern .class file format. The recommended Error:solution is to recompile the class from source, using an up-to-date compiler Error:and without specifying any "-target" type options. The consequence of ignoring Error:this warning is that reflective operations on this class will incorrectly Error:indicate that it is *not* an inner class. Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:(org.apache.log4j.lf5.viewer.LogBrokerMonitor$2) that doesn't come with an Error:associated EnclosingMethod attribute. This class was probably produced by a Error:compiler that did not target the modern .class file format. The recommended Error:solution is to recompile the class from source, using an up-to-date compiler Error:and without specifying any "-target" type options. The consequence of ignoring Error:this warning is that reflective operations on this class will incorrectly Error:indicate that it is *not* an inner class. Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:(org.apache.log4j.lf5.viewer.LogBrokerMonitor$20) that doesn't come with an Error:associated EnclosingMethod attribute. This class was probably produced by a Error:compiler that did not target the modern .class file format. The recommended Error:solution is to recompile the class from source, using an up-to-date compiler Error:and without specifying any "-target" type options. The consequence of ignoring Error:this warning is that reflective operations on this class will incorrectly Error:indicate that it is *not* an inner class. Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:(org.apache.log4j.lf5.viewer.LogBrokerMonitor$21) that doesn't come with an Error:associated EnclosingMethod attribute. This class was probably produced by a Error:compiler that did not target the modern .class file format. The recommended Error:solution is to recompile the class from source, using an up-to-date compiler Error:and without specifying any "-target" type options. The consequence of ignoring Error:this warning is that reflective operations on this class will incorrectly Error:indicate that it is *not* an inner class. Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:(org.apache.log4j.lf5.viewer.LogBrokerMonitor$22) that doesn't come with an Error:associated EnclosingMethod attribute. This class was probably produced by a Error:compiler that did not target the modern .class file format. The recommended Error:solution is to recompile the class from source, using an up-to-date compiler Error:and without specifying any "-target" type options. The consequence of ignoring Error:this warning is that reflective operations on this class will incorrectly Error:indicate that it is *not* an inner class. Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:(org.apache.log4j.lf5.viewer.LogBrokerMonitor$23) that doesn't come with an Error:associated EnclosingMethod attribute. This class was probably produced by a Error:compiler that did not target the modern .class file format. The recommended Error:solution is to recompile the class from source, using an up-to-date compiler Error:and without specifying any "-target" type options. The consequence of ignoring Error:this warning is that reflective operations on this class will incorrectly Error:indicate that it is *not* an inner class. Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:(org.apache.log4j.lf5.viewer.LogBrokerMonitor$24) that doesn't come with an Error:associated EnclosingMethod attribute. This class was probably produced by a Error:compiler that did not target the modern .class file format. The recommended Error:solution is to recompile the class from source, using an up-to-date compiler Error:and without specifying any "-target" type options. The consequence of ignoring Error:this warning is that reflective operations on this class will incorrectly Error:indicate that it is *not* an inner class. Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:(org.apache.log4j.lf5.viewer.LogBrokerMonitor$25) that doesn't come with an Error:associated EnclosingMethod attribute. This class was probably produced by a Error:compiler that did not target the modern .class file format. The recommended Error:solution is to recompile the class from source, using an up-to-date compiler Error:and without specifying any "-target" type options. The consequence of ignoring Error:this warning is that reflective operations on this class will incorrectly Error:indicate that it is *not* an inner class. Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:(org.apache.log4j.lf5.viewer.LogBrokerMonitor$26) that doesn't come with an Error:associated EnclosingMethod attribute. This class was probably produced by a Error:compiler that did not target the modern .class file format. The recommended Error:solution is to recompile the class from source, using an up-to-date compiler Error:and without specifying any "-target" type options. The consequence of ignoring Error:this warning is that reflective operations on this class will incorrectly Error:indicate that it is *not* an inner class. Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:(org.apache.log4j.lf5.viewer.LogBrokerMonitor$27) that doesn't come with an Error:associated EnclosingMethod attribute. This class was probably produced by a Error:compiler that did not target the modern .class file format. The recommended Error:solution is to recompile the class from source, using an up-to-date compiler Error:and without specifying any "-target" type options. The consequence of ignoring Error:this warning is that reflective operations on this class will incorrectly Error:indicate that it is *not* an inner class. Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:(org.apache.log4j.lf5.viewer.LogBrokerMonitor$28) that doesn't come with an Error:associated EnclosingMethod attribute. This class was probably produced by a 

已安装的SDK:

所有包括修改。 25.1.2

Android Studio:

Android Studio 2.0 Build#AI-143.2739321,构build于2016年4月5日JRE:1.7.0_80-b15 amd64

该项目的build.gradle文件:

 apply plugin: 'com.android.application' android { signingConfigs { mulco { storeFile file("somePath") storePassword "..." keyAlias "..." keyPassword "..." } } compileSdkVersion 22 buildToolsVersion "22.0.1" def versionPropertiesFile = file('version.properties') if (versionPropertiesFile.canRead()) { def Properties versionProps = new Properties() versionProps.load(new FileInputStream(versionPropertiesFile)) def code = versionProps['VERSION_CODE'].toInteger() + 1 versionProps['VERSION_CODE'] = code.toString() println('count version up ' + code.toString()) versionProps.store(versionPropertiesFile.newWriter(), null) defaultConfig { multiDexEnabled true signingConfig signingConfigs.mulco applicationId "com.test.mulcoandroid" minSdkVersion 19 targetSdkVersion 22 versionCode code versionName "1.03.01" } } else { throw new GradleException("Could not read version.properties!") } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' signingConfig signingConfigs.mulco } debug { debuggable true signingConfig signingConfigs.mulco } } packagingOptions { exclude 'META-INF/LICENSE.txt' exclude 'META-INF/NOTICE.txt' } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.google.android.gms:play-services-maps:8.4.0' compile project(':iCommonLibrary') compile project(':mulcobluetooth') compile project(':iScannerLibrary') compile project(':iPictureLibrary') compile 'com.android.support:multidex:1.0.1' testCompile "junit:junit:4.12" compile 'net.lingala.zip4j:zip4j:1.3.2' } 

和依赖的iCommonLibrary:

 apply plugin: 'com.android.library' android { compileSdkVersion 22 buildToolsVersion "22.0.1" defaultConfig { multiDexEnabled true minSdkVersion 16 targetSdkVersion 22 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } packagingOptions { exclude 'META-INF/LICENSE.txt' exclude 'META-INF/NOTICE.txt' } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.squareup.retrofit:retrofit:1.9.0' compile 'com.squareup.okhttp:okhttp:2.5.0' compile 'de.greenrobot:greendao:1.3.7' compile 'commons-io:commons-io:2.4' compile 'org.apache.commons:commons-lang3:3.3.2' compile 'commons-codec:commons-codec:1.10' compile 'de.mindpipe.android:android-logging-log4j:1.0.3' compile 'org.slf4j:slf4j-api:1.6.4' compile 'org.slf4j:slf4j-log4j12:1.6.4' compile 'com.google.android.gms:play-services-location:8.4.0' compile 'commons-net:commons-net:3.3' compile 'com.jjoe64:graphview:4.0.1' compile 'com.android.support:support-annotations:22.0.1' } 

iPictureLibrary的build.gradle:

 apply plugin: 'com.android.library' android { compileSdkVersion 22 buildToolsVersion "22.0.1" defaultConfig { minSdkVersion 19 targetSdkVersion 22 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'it.sephiroth.android.library.horizontallistview:hlistview:1.2.2' compile 'com.android.support:appcompat-v7:22.2.0' compile 'com.jakewharton:disklrucache:2.0.2' compile project(':iCommonLibrary') } 

iScannerLibrary的build.gradle:

 apply plugin: 'com.android.library' android { compileSdkVersion 22 buildToolsVersion "22.0.1" defaultConfig { minSdkVersion 16 targetSdkVersion 22 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.google.zxing:core:3.2.1' compile 'com.google.zxing:android-core:3.2.1' compile files('libs/GrabbaSDK/Grabba driver for android v1.122.jar') compile project(':iCommonLibrary') } 

build.gradle文件的mulcobluetooth:

 apply plugin: 'com.android.library' android { compileSdkVersion 22 buildToolsVersion "22.0.1" defaultConfig { minSdkVersion 16 targetSdkVersion 22 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } defaultConfig { multiDexEnabled true } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'org.apache.commons:commons-lang3:3.3.2' compile 'commons-io:commons-io:2.4' } 

我希望我提供了任何重要的信息

如果有人知道什么…请帮助我! 我在这个“NEULAND”中找不到任何东西

对不起,很长的问题…感谢任何人已经到这里。

编辑:

我更新了依赖关系:

 compile 'org.apache.logging.log4j:log4j-core:2.5' compile 'org.slf4j:slf4j-api:1.7.21' compile 'org.slf4j:slf4j-log4j12:1.7.21' 

但没有任何改变。 我仍然有大约500个构build错误….我删除了mindpipe作为参考编码它自己…什么都没有发生!

编辑:

打开一张票:问题206867

https://code.google.com/p/android/issues/detail?id=206867

编辑:

卸载Android Studio 2.0并再次安装1.5.1后,我收到以下警告:

警告:Gradle版本2.10是必需的。 当前版本是2.8。 如果使用gradle包装,尝试编辑C:\ Sources \ iRecyApps \ iRecyMulco-1.0.1iOS \ gradle \ wrapper \ gradle-wrapper.properties中的distributionUrl到gradle-2.10-all.zip

所以gradle版本更新了2 …

我告诉自己当前的gradle版本,它是2.12

我下载了两个,并试图这样做:

您需要更改文件>设置>构build,执行,部署>构build工具> Gradle> Gradle主path

在Mac OS上,更改Android Studio>首选项>生成,执行,部署>生成工具> Gradle> Gradle home

或者设置使用默认的Gradle包装器,并像这样编辑Project \ gradle \ wrapper \ gradle-wrapper.properties文件字段distributionUrl

根据:

“Gradle版本2.10是必需的。” 错误

http://tools.android.com/tech-docs/new-build-system/version-compatibility

依然没有

Solutions Collecting From Web of "在用log4j更新Android Studio之后,Gradle构build时出错"

将此行添加到proguard-rules.pro

 -keepattributes EnclosingMethod 

这个错误几乎可能发生在所有具有InnerClasses的类上,我想。 (如support.v4等)对我来说。


我已经testing了Android Studio 2.2
(未testinglog4j,testingsupport.v4等)

的build.gradle

 compileSdkVersion 24 buildToolsVersion "24.0.2" ... minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' ... dependencies { ... compile 'com.android.support:support-v4:24.2.1' } 

getDefaultProguardFile('proguard-android-optimize.txt')也可以。

我也面临同样的错误。 这让我疯狂,因为错误数大于1K。 而且我在启用了proguard的版本构build中遇到了这些错误。

在做了一些挖掘之后,我发现在你的proguard-rules.pro文件中添加-keepattributes EnclosingMethod ,所有这些错误都将消失。

来源 : 主题和GitHub上的问题#294 。

通过在Gradleconfiguration中将所有com.android.support依赖关系降级到23.1.1解决。

就我而言,当我使Instant Run启用时遇到了这个错误,但在禁用Instant Run ,错误消失了。 在这里输入图像说明

把这个代码片段写在你项目中的proguard-rules.pro中。

 -keepattributes EnclosingMethod 

通过将上面的代码片段写入proguard-rules.pro文件,proguard规则实际上改变了类的模糊处理方式。

这工作对我来说,开始一个新的Android工作室项目副本,并粘贴gradle-wrapper.properties和build.gradle(项目:“项目名称”)在您的旧项目中有错误 – 为了升级您的Gradle

在你的proguard-rules.pro中添加这个

 -keepattributes EnclosingMethod 

更新你的build.gradle(模块:应用程序)如下

 buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } dexOptions { preDexLibraries = false }