Proguard issue “Warning:Ignoring InnerClasses attribute for an anonymous inner class”

前端 未结 8 1618
灰色年华
灰色年华 2020-12-08 02:06

I don\'t know how I can describe this issue. I searched a lot, but I didn\'t find any solution.

Also this solution did not help me -keepattributes EnclosingMethod:

相关标签:
8条回答
  • 2020-12-08 02:48

    You've got 2 problems here.

    1) Warning:Ignoring InnerClasses attribute for an anonymous inner class ......

    It's just a warning. If your code works properly you can ignore it by disabling Lint in the .gradle file:

    android {
        ...
        lintOptions {
            abortOnError false
        }
    }
    

    2) translation error: attempt to set or access a value of type int using a local variable of type android.support.design.widget.CoordinatorLayout$LayoutParams

    This looks like in some place ProGuard optimizes variable allocation, but does it incorrectly.

    Try to disable this optimization by adding the line below in your ProGuard file:

    -optimizations !code/allocation/variable

    0 讨论(0)
  • 2020-12-08 02:51

    Add dex.force.jumbo=true into your gradle.properties. It works for me.

    0 讨论(0)
  • 2020-12-08 02:53

    I resolved a similar issue by updating the compile SDK, target SDK version, and support libraries version.

    0 讨论(0)
  • 2020-12-08 02:55

    I've noticed that often the cause for this problem is when proguard-android.txt file is not referenced in the project, as it contains the correct configuration to avoid this issue:

    # Preserve some attributes that may be required for reflection.
    -keepattributes *Annotation*,Signature,InnerClasses,EnclosingMethod
    

    Solution

    Make sure to add this file to your project, along with your own ProGuard configuration files, for example:

    release {
        minifyEnabled true
        setProguardFiles([getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'])
    }
    

    The file is contained in the SDK so your gradle build will pick it up automatically, you don't need to copy it to your project.

    0 讨论(0)
  • 2020-12-08 02:58

    Try adding

    -keepattributes InnerClasses
    -dontoptimize
    

    to the ProGuard config. That should fix the problem.

    It's probable that incompatible optimizations are applied (that probably causes the last line of the error log).

    If you want to allow optimizations, it's necessary to fine tune optimizations config with

    -optimizations optimization_filter 
    

    option in ProGuard config.

    0 讨论(0)
  • 2020-12-08 03:00

    For me what solved the problem was to use a newer version of jar. The clue was:

    This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler.

    So i changed from:

        compile 'com.google.inject:guice:4.0'
    

    to:

        compile 'com.google.inject:guice:4.2.0'
    
    0 讨论(0)
提交回复
热议问题