Android Build fails using Proguard and Gradle

倾然丶 夕夏残阳落幕 提交于 2020-01-01 12:16:07

问题


I have recently converted a project from eclipse/ant to using Android Studio/Gradle. My debug build works fine but when I attempt to do a release build with proguard enabled it fails with the following error

16:26:13.437 [ERROR] [system.err] Unexpected error while computing stack sizes:
16:26:13.438 [ERROR] [system.err]   Class       = [com/a/a/a/d/d]
16:26:13.438 [ERROR] [system.err]   Method      = [<clinit>()V]
16:26:13.438 [ERROR] [system.err]   Exception   = [java.lang.IllegalArgumentException] (Stack size becomes negative after instruction [143] swap in [com/a/a/a/d/d.<clinit>()V])

I have used the same proguard.txt for my eclipse project and it worked fine so it suggests there is some kind of problem with the Gradle Android plugin. Has anyone encountered a similar problem? My proguard config - http://pastebin.com/2gsNUmeD and full gradle output http://pastebin.com/TAvMUSrR


回答1:


ProGuard should indeed behave identically in Ant, Eclipse, and Gradle. You should check if your builds use different versions of ProGuard. You can see the version in the console log. If you know which ProGuard jar is being used, you can also type java -jar proguard.jar to get the version.

The error message suggests a bug in ProGuard's optimization step. Hopefully the bug occurs in an older version and not in newer versions. You can then simply upgrade the jar. Otherwise, you can report it on ProGuard's bug tracker, preferably with sufficient information to reproduce the problem. As a workaround, you can disable optimization with the option -dontoptimize.



来源:https://stackoverflow.com/questions/18833400/android-build-fails-using-proguard-and-gradle

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