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

心已入冬 提交于 2019-11-28 04:37:57

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.

Adding these lines to proguard-rules.pro file fixed my issue.

-keepattributes EnclosingMethod
-keepattributes InnerClasses

I suggest -dontwarn InnerClasses

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.

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

Sanket Parchande

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

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'
Victor Zaffalon

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!