App works perfectly on 1.6, but why am I getting java.lang.VerifyError on Xperia X10 running 1.6?

孤人 提交于 2019-12-03 22:11:44

ProGuard's optimization step will inline methods like VersionHelper#overrideTransition(), which is not what you want, since the method is intended to isolate the dependency on 1.6 (although ProGuard can't know this).

Brute-force solution: switch off all optimizations:

-dontoptimize

Finer-grained: switch off all method inlining (as you've found out):

-optimizations !method/inlining/*

Ideal solution: avoid inlining this particular method and its siblings:

-keepclassmembers,allowobfuscation,allowshrinking somepackage.VersionHelper {
  <methods>;
}

Without details, I can't say much about the other issues. You can ask questions on ProGuard's help forum.

Your com.twocell.walkabout.Animator class implementation is referring to some class or method that does not exist on the Xperia X10. It does not have to be limited to something in the static setLayoutAnimation_textFadeIn() method -- it can be anything on that class. Unfortunately, the VerifyError does not say what cannot be found.

You will have to go through your application with a fine-toothed comb and determine what might be missing on the Xperia X10 that exists elsewhere.

but if that were the case wouldn't the problem exist on every device running 1.6, instead of just the X10?

Yes.

The solution was to add -optimizations !method/inlining/unique to proguard.cfg, which according to ProGuard's docs normally "Inlines methods that are only called once". I wish I could say I figured that out without excluding every single optimization then removing them one by one as I built signed releases... but that's exactly what I did.

Edit (new info)

As I continue working I'm discovering that there are other parts of my app that are crashing on the X10, and require other specific optimization exclusions to work properly. I'm also beginning to see a pattern with crash reports from other specific devices that simply should not be happening, and in fact don't happen on my own test devices and emulators.

I am forced to conclude that I cannot trust ProGuard's optimizations at this point. Since the problems only occur on specific devices, I'm more likely to place blame on manufacturer customizations, and not ProGuard. Finding the actual link between the two is beyond my capability.

So my final solution is to use -dontoptimize or risk getting 1-star reviews due to unsolvable problems. Neat. I've never been one to complain about platform fragmentation until now. This particular discovery is a serious disappointment.

Edit 2 (followup)

Since I pushed an update removing the optimization outright, all crashing has stopped. Now I can finally get back to feature development.

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