4

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

4

1 回答 1

2

ProGuard 在 Ant、Eclipse 和 Gradle 中的行为确实应该相同。您应该检查您的构建是否使用不同版本的 ProGuard。您可以在控制台日志中查看版本。如果您知道正在使用哪个 ProGuard jar,您还可以键入java -jar proguard.jar以获取版本。

该错误消息表明 ProGuard 的优化步骤中存在错误。希望该错误发生在旧版本中,而不是新版本中。然后,您可以简单地升级 jar。否则,您可以在ProGuard 的错误跟踪器上报告它,最好有足够的信息来重现问题。作为一种解决方法,您可以使用选项禁用优化-dontoptimize

于 2013-09-21T00:05:59.587 回答