LoginSignup
18

More than 5 years have passed since last update.

Android Studio 2.2へのアップデートで起こる『Ignoring InnerClasses attribute…』エラー

Last updated at Posted at 2016-10-05

起こるエラー

Android Studioを2.2、gradleを2.2に更新した状態でProguardをかけてビルドすると、こんなエラーがたくさん出るようになってしまった。

Error: warning: Ignoring InnerClasses attribute for an anonymous inner class
(android.support.v4.app.ActivityCompat$1) that doesn't come with an
associated EnclosingMethod attribute. 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
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.

こんなエラーが、数千のクラスに対して発生。

内容的としては、新しい環境でビルドをやりなおせ!ってことなんだろうけど、mavenCentralからなど、他の人が作ったライブラリーを使ってるのがほとんどなので、ビルドし直して使うのはあまりやりたくはないし、現実的ではない。

対処法

これをproguard-rules.proに追加してください。
-keepattributes EnclosingMethod

EnclosingMethodに対して、Proguardをかけないっていう設定です。
InnerClassesに手をつけないでくれるので、問題なくビルド・難読化ができるようになるというわけです。
これをつけてビルドし直すと、ごそっとエラーがなくなります。

参考リンク

What is the “Ignoring InnerClasses attribute” warning output during compilation?

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
18