开发者

weirdest Exception ever when androiding

开发者 https://www.devze.com 2023-02-22 02:33 出处:网络
java.lang.RuntimeException: Unable to start activity....java.lang.ClassCastException: android.widget.RelativeLayout

java.lang.RuntimeException: Unable to start activity....java.lang.ClassCastException: android.widget.RelativeLayout

I got this exception out of nowhere; this happens when I was actually trying to activate a new activity which, a second ago, ran fine. I tried everything, force stop the app, uninstall the app, restart eclipse, restart computer, none of which works. Then it occurred it me that there was a time when I fixed a problem like this by just closing the layout XML file and reopening it. So I tried that, and it didn't work. So I tried the one last thing: I copied out the layout XML file's content, deleted the X开发者_如何转开发ML file, and created another XML layout file with the same name, copied the stuff back in, and it worked! How could this be? Is it a bug of the eclipse plugin? It cost me 3 hours just to find this nonsense; I'm pissed.


I've seen that exception when I was editing some smali files and repackaging the apk. In those cases, the problem was that resources.arsc was zipped with compression instead of stored. Sometimes that messes up all the xml structure and android is unable to read it correctly. It could be some weird Eclipse bug when repackaging the apk, and it would not be the only one. From time to time, I get and error exclamation mark in one of the android projects, usually one that I did not touch in a while. I don't really know what triggers that, though.


I ran into this problem using both IntelliJ and Ant to build a package. It didn't matter if it was a debug version or signed release version both failed on startup. However, after running ant clean everything began working again.

0

精彩评论

暂无评论...
验证码 换一张
取 消