2016-12-29 68 views
0

已經嘗試過
-keepattributes EnclosingMethod 和-dontwarn InnerClasses上proguard-rules.pro
並沒有成功:(
你們有什麼祕訣嗎?Android - 如何消除這些gradle/proguard警告?

Information:Gradle tasks [:app:assembleMobilePFDebug] Error:warning: Ignoring InnerClasses attribute for an anonymous inner class Error:(net.lingala.zip4j.util.ArchiveMaintainer$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:(net.lingala.zip4j.util.ArchiveMaintainer$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:(net.lingala.zip4j.unzip.Unzip$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:(net.lingala.zip4j.unzip.Unzip$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:(net.lingala.zip4j.zip.ZipEngine$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:(com.samsung.android.sdk.pass.c) 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:(com.samsung.android.sdk.pass.d) 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:(com.samsung.android.sdk.pass.a) 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:(com.samsung.android.sdk.pass.b) 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:(com.samsung.android.sdk.pass.e) 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. Information:BUILD SUCCESSFUL Information:Total time: 1 mins 43.541 secs Information:80 errors Information:0 warnings Information:See complete output in console

搖籃文件(它的主要部分) :

apply plugin: 'com.android.application' 
apply plugin: 'jacoco' 

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.1" 

    dexOptions{ 
     maxProcessCount 3 
     javaMaxHeapSize "2g" 
    } 

    defaultConfig { 
     applicationId "com.xyz" 
     minSdkVersion 19 
     targetSdkVersion 22 
     versionCode 1 
     testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner' 
     multiDexEnabled true 
    } 

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

    testOptions { 
     unitTests.returnDefaultValues = true 
    } 

    task jacocoTestReport(type: JacocoReport, dependsOn: "test"){ 

     group = "Reporting" 
     description = "Generate Jacoco coverage reports after running tests." 

     reports { 
      xml.enabled = true 
      html.enabled = true 
     } 

     classDirectories = fileTree(
       dir: "./build/intermediates/classes/debug", 
       excludes: [ '**/R*.class', 
          '**/*$InjectAdapter.class', 
          '**/*$ModuleAdapter.class', 
          '**/*$ViewInjector.class'] 
     ) 

     def coverageSourceDirs = [ 
       "src/main/java" 
     ] 

     sourceDirectories = files(coverageSourceDirs) 
     executionData = files("${project.buildDir}/jacoco/${jacocoTestReport}.exec") 
    } 

    productFlavors { 
     xyz { 
      applicationId "com.xyz" 
      versionName "1.2" 
      resValue "string", "app_name", "xyz" 
      versionCode "1" 
     } 
    } 
    packagingOptions { 
     exclude 'META-INF/DEPENDENCIES.txt' 
     exclude 'META-INF/LICENSE.txt' 
     exclude 'META-INF/NOTICE.txt' 
     exclude 'META-INF/NOTICE' 
     exclude 'META-INF/LICENSE' 
     exclude 'META-INF/DEPENDENCIES' 
     exclude 'META-INF/notice.txt' 
     exclude 'META-INF/license.txt' 
     exclude 'META-INF/dependencies.txt' 
     exclude 'META-INF/LGPL2.1' 
    } 
} 

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    compile 'com.android.support:appcompat-v7:23.4.0' 
    compile 'com.android.support:design:23.4.0' 
    testCompile fileTree(include: ['*.jar'], dir: 'libs/testLibs') 
    testCompile 'junit:junit:4.12' 
    androidTestCompile fileTree(include: ['*.jar'], dir: 'libs/androidTestLibs') 
    androidTestCompile 'com.android.support:support-annotations:23.4.0' 
    androidTestCompile 'junit:junit:4.12' 
    androidTestCompile 'com.android.support.test:runner:0.5' 
    androidTestCompile 'org.mockito:mockito-core:1.10.19' 
    compile 'me.dm7.barcodescanner:zxing:1.8.4' 
    compile 'com.google.code.gson:gson:2.4' 
    compile files('libs/zip4j_1.3.2.jar') 
} 


android.applicationVariants.all { variant -> 
    variant.javaCompile.options.compilerArgs += [ 
      '-AresourcePackageName=com.xyz' 
    ] 
} 

Java的版本& &的javac -version
Java版本 「1.7.0_71」
的Java(TM)SE運行時環境(建立1.7.0_71-B14)
爪哇熱點(TM)64位服務器VM(建立24.71-B01,混合模式)
javac的1.7 .0_71

+0

什麼是您的java(JDK)版本? – naXa

+0

嘗試清理並重建您的項目。 – mbacvanski

+0

已經嘗試清洗和重建, –

回答

0

更新

試試這個行:

-keepattributes InnerClasses,EnclosingMethod,Signature 

這個問題類似於此post。基本上,您只需要將此行添加到您的proguard-rules.pro文件中:

-keepattributes EnclosingMethod 
+0

嗨...我試過了,不幸的是由於某種原因,在我的情況下沒有任何效果 –

+0

更新了答案。讓我知道這是否有效。 –

+0

使用更新的答案沒有效果:( –