使用log4j更新Android Studio后,gradle构建出错

时间:2021-10-28 18:53:56

I do get these errors after i updated Android Studio and the SDK:

在我更新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

Installed SDK:

All including rev. 25.1.2

全部包括转速。 25.1.2

Android Studio:

Android Studio 2.0 Build #AI-143.2739321, built on April 5, 2016 JRE: 1.7.0_80-b15 amd64

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

The build.gradle file of the project:

项目的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'
}

and of the dependant iCommonLibrary:

和依赖的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'
}

build.gradle of iPictureLibrary:

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')
}

build.gradle of iScannerLibrary:

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 file of mulcobluetooth:

mulcobluetooth的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'
    }
}

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

I hope i provided any important information

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

If someone does know anything ... please help me! I cannot find anything in this "NEULAND"

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

Sorry for the long question... Thanks for anyone who has made it up to here.

很抱歉这个问题很长...感谢所有来到这里的人。

EDIT:

I updated the dependencies to:

我将依赖项更新为:

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'

But nothing has changed. I still have about 500 build errors .... I deleted mindpipe as reference an coded it by myself ... Nothing happened!

但一切都没有改变。我仍然有大约500个构建错误....我删除了mindpipe作为参考,我自己编码...没有发生任何事情!

EDIT:

Opened a ticket: Issue 206867

开票:问题206867

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

EDIT:

After uninstall Android Studio 2.0 and install 1.5.1 again I get the following warning:

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

Warning:Gradle version 2.10 is required. Current version is 2.8. If using the gradle wrapper, try editing the distributionUrl in C:\Sources\iRecyApps\iRecyMulco-1.0.1iOS\gradle\wrapper\gradle-wrapper.properties to gradle-2.10-all.zip

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

So the gradle version was updated by 2...

所以gradle版本更新了2 ...

I informed myself about the current gradle version and it's 2.12

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

I downloaded both and tried this:

我下载了两个并试过这个:

You need to change File > Settings > Builds,Execution,Deployment > Build Tools > Gradle >Gradle home path

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

On Mac OS, change the path in Android Studio > Preferences > Builds,Execution,Deployment > Build Tools > Gradle >Gradle home

在Mac OS上,更改Android Studio中的路径>首选项>构建,执行,部署>构建工具> Gradle> Gradle home

Or set Use default gradle wrapper and edit Project\gradle\wrapper\gradle-wrapper.properties files field distributionUrl like this

或者设置Use default gradle wrapper并编辑Project \ gradle \ wrapper \ gradle-wrapper.properties文件字段distributionUrl,像这样

according to:

"Gradle Version 2.10 is required." Error

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

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

Still nothing

6 个解决方案

#1


21  

Add this line to proguard-rules.pro

将此行添加到proguard-rules.pro

-keepattributes EnclosingMethod

This error may happen almost all classes which has InnerClasses, I think. (like support.v4 etc) for me.

我想,几乎所有具有InnerClasses的类都可能发生此错误。 (对于support.v4等)对我来说。


I've tested on Android studio 2.2
(Not tested log4j. Tested support.v4 etc.)

我在Android studio 2.2上测试过(未测试过log4j。经过测试的support.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') also works.

getDefaultProguardFile('proguard-android-optimize.txt')也有效。

#2


4  

I was also facing this same error. It was driving me crazy because the error count was >1K. And I was getting these errors on release build with proguard enabled.

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

After doing some digging I found that adding -keepattributes EnclosingMethod in your proguard-rules.pro file all these error will be gone.

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

Source: Thread and Issue #294 on GitHub.

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

#3


0  

Solved by downgrading all com.android.support dependencies to 23.1.1 in Gradle configuration.

通过在Gradle配置中将所有com.android.support依赖项降级为23.1.1来解决此问题。

#4


0  

In my case,I met this error when I made Instant Run enable,but after disable Instant Run,the error was disappeared.使用log4j更新Android Studio后,gradle构建出错

在我的情况下,我在启用“即时运行”时遇到此错误,但在禁用“即时运行”后,错误消失了。

#5


0  

Write this code snippet in proguard-rules.pro in your project.

在项目中的proguard-rules.pro中编写此代码段。

-keepattributes EnclosingMethod

By writing above snippet to proguard-rules.pro file, the proguard rules actually changes how the classes are obfuscated.

通过将上面的代码段写入proguard-rules.pro文件,proguard规则实际上会更改类的混淆方式。

#6


0  

This worked for me, start a new Android studio project copy and paste gradle-wrapper.properties and build.gradle (Project: "Project Name") in your old project that had the error - in order to upgrade your gradle

这对我有用,启动一个新的Android工作室项目复制并粘贴gradle-wrapper.properties和build.gradle(项目:“项目名称”)在你的旧项目中有错误 - 为了升级你的gradle

Also add this in your proguard-rules.pro

另外在proguard-rules.pro中添加它

-keepattributes EnclosingMethod

Update your build.gradle (Module:app) as follows

更新build.gradle(Module:app),如下所示

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

    }

    dexOptions {
        preDexLibraries = false
    }

#1


21  

Add this line to proguard-rules.pro

将此行添加到proguard-rules.pro

-keepattributes EnclosingMethod

This error may happen almost all classes which has InnerClasses, I think. (like support.v4 etc) for me.

我想,几乎所有具有InnerClasses的类都可能发生此错误。 (对于support.v4等)对我来说。


I've tested on Android studio 2.2
(Not tested log4j. Tested support.v4 etc.)

我在Android studio 2.2上测试过(未测试过log4j。经过测试的support.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') also works.

getDefaultProguardFile('proguard-android-optimize.txt')也有效。

#2


4  

I was also facing this same error. It was driving me crazy because the error count was >1K. And I was getting these errors on release build with proguard enabled.

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

After doing some digging I found that adding -keepattributes EnclosingMethod in your proguard-rules.pro file all these error will be gone.

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

Source: Thread and Issue #294 on GitHub.

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

#3


0  

Solved by downgrading all com.android.support dependencies to 23.1.1 in Gradle configuration.

通过在Gradle配置中将所有com.android.support依赖项降级为23.1.1来解决此问题。

#4


0  

In my case,I met this error when I made Instant Run enable,but after disable Instant Run,the error was disappeared.使用log4j更新Android Studio后,gradle构建出错

在我的情况下,我在启用“即时运行”时遇到此错误,但在禁用“即时运行”后,错误消失了。

#5


0  

Write this code snippet in proguard-rules.pro in your project.

在项目中的proguard-rules.pro中编写此代码段。

-keepattributes EnclosingMethod

By writing above snippet to proguard-rules.pro file, the proguard rules actually changes how the classes are obfuscated.

通过将上面的代码段写入proguard-rules.pro文件,proguard规则实际上会更改类的混淆方式。

#6


0  

This worked for me, start a new Android studio project copy and paste gradle-wrapper.properties and build.gradle (Project: "Project Name") in your old project that had the error - in order to upgrade your gradle

这对我有用,启动一个新的Android工作室项目复制并粘贴gradle-wrapper.properties和build.gradle(项目:“项目名称”)在你的旧项目中有错误 - 为了升级你的gradle

Also add this in your proguard-rules.pro

另外在proguard-rules.pro中添加它

-keepattributes EnclosingMethod

Update your build.gradle (Module:app) as follows

更新build.gradle(Module:app),如下所示

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

    }

    dexOptions {
        preDexLibraries = false
    }