简体   繁体   中英

Android - How to eliminate these gradle/proguard warnings?

Already tried
-keepattributes EnclosingMethod and -dontwarn InnerClasses
on proguard-rules.pro and no success :(
You guys got any tips?

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

Gradle file(main parts of it):

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 -version && javac -version
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)
javac 1.7.0_71

Update

Try this line instead:

-keepattributes InnerClasses,EnclosingMethod,Signature

This issue is similar to this post . Basically, you just need to add this line to your proguard-rules.pro file:

-keepattributes EnclosingMethod

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM