java.lang.VerifyError on Android
For the, you learn something everyday file.
Google shows you in the Backwards Compatibility and Using the Contacts API articles the right ways to write code for two versions of an API, but they don't tell you why this is important.
It turns out that JVM and Dalvik do a byte code verify on class load, and if there's something that's not supposed to be there, like a new API call, it won't load the class. (Ya, well duh!) I've read about it over the years, but never needed to do it until recently. It's of course fairly easy to fix, once you realize it, you've just got to put your new API code in it's own class, and only load the class when you need to. Or you can do it via reflection. I.e. it's a pain, but useful if you want just one binary. (APK, JAR, WAR, etc.)
Google shows you in the Backwards Compatibility and Using the Contacts API articles the right ways to write code for two versions of an API, but they don't tell you why this is important.
It turns out that JVM and Dalvik do a byte code verify on class load, and if there's something that's not supposed to be there, like a new API call, it won't load the class. (Ya, well duh!) I've read about it over the years, but never needed to do it until recently. It's of course fairly easy to fix, once you realize it, you've just got to put your new API code in it's own class, and only load the class when you need to. Or you can do it via reflection. I.e. it's a pain, but useful if you want just one binary. (APK, JAR, WAR, etc.)
Labels: Android


0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home