How can I fix this unusual bug that is causing my android app to crash on certain phones?
I have recently completed development on a game for Android smartphones.
It was designed using the android 2.1 sdk and runs no problem on my test devices a 2.1 samsung galaxy europa and a 2.2 samsung galaxy tab and seems to run fine in the emulator for 2.3.3.
Up until r开发者_StackOverflowecently it ran fine on my friends HTC desire S but suddenly it stopped working, crashing on start.
It would appear that the error is caused by a resource not being found.
This code has not been touched for the past 2 months and ran no problem on my 2.1 and 2.2 devices but I must have done something. It seems that suddenly that some phones can't see the resources but unfortunately I cannot replicate this bug and my friend is not around enough and is getting quite pissed at me for pestering him for me to take his phone and keep trying to fix it.
Any help would be much appreciated as this is driving me mad especially as I cannot replicate this bug with any of my equipment. I haven't even got a confirmation that it works on 2.3.3 as the people who have downloaded my app aren't leaving any useful feedback or submitting many error reports. Hopefully it is just a bug with HTC's variant of android.
I sometimes have errors like this when I'm rapidly iterating (tweak/test) on the emulator. They're usually solved by doing an "ant clean" and then recompiling. You could try cleaning and then doing a fresh build, installing it on your friends device, and then seeing if you still get the error.
-Kurtis
Have you considered/researched whether or not this actually is a resource problem...meaning does this resource actually exist in the folder Android is trying to draw from?
I'm currently facing the crash in a production application and have found the problem. This crash is only happening on HTC devices. Seems like HTC changed the core Android method that decode a Resource.
The documentation of BitmapFactory.decodeResource
says :
Returns
The decoded bitmap, or null if the image could not be decode.
But HTC version of that crashes :(
In my case, I had mis-placed the "xml" folder. It was on the root of the project, but just moved within "/res" folder and the error was gone.
精彩评论