Application runs fine on Eclipse emulator but errors on the phone - FroYo

1k views Asked by At

I've got an application which (although I'm not sure why,) requires Android 2.2 at least to work, so after getting Froyo on my phone, I tested the application and although it installs and begins to run, when I carry out a function, it results in the following error:

"The application has stopped unexpected. Please try again."

It works fine on the emulator which is also running Froyo so I can't figure out what the problem is. The error in adb logcat is the following:

W/dalvikvm( 1027): threadid=1: thread exiting with uncaught exception (group=0x2aacc8a0)

And it gives a null pointer exception, except I know that there isn't a null pointer exception as it works fine in the emulator and I can see from the System.out in adb logcat that the value won't be null.

Does anyone have any idea on what I can do to fix this?

Thank you for your time!

Edit: Here is the stack as requested:

W/dalvikvm( 861): threadid=1: thread exiting with uncaught exception (group=0x2aacc8a0) E/AndroidRuntime( 861): FATAL EXCEPTION: main E/AndroidRuntime( 861): java.lang.NullPointerException E/AndroidRuntime( 861): at com.andrWow.wCraftArmory.Armory.updateUI(Armory.java:150) E/AndroidRuntime( 861): at com.andrWow.wCraftArmory.Armory.access$2(Armory.java:140) E/AndroidRuntime( 861): at com.andrWow.wCraftArmory.Armory$carryOutSearch.onPostExecute(Armory.java:282) E/AndroidRuntime( 861): at com.andrWow.wCraftArmory.Armory$carryOutSearch.onPostExecute(Armory.java:1) E/AndroidRuntime( 861): at android.os.AsyncTask.finish(AsyncTask.java:417) E/AndroidRuntime( 861): at android.os.AsyncTask.access$300(AsyncTask.java:127) E/AndroidRuntime( 861): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429) E/AndroidRuntime( 861): at android.os.Handler.dispatchMessage(Handler.java:99) E/AndroidRuntime( 861): at android.os.Looper.loop(Looper.java:123) E/AndroidRuntime( 861): at android.app.ActivityThread.main(ActivityThread.java:4627) E/AndroidRuntime( 861): at java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime( 861): at java.lang.reflect.Method.invoke(Method.java:521) E/AndroidRuntime( 861): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:876) E/AndroidRuntime( 861): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634) E/AndroidRuntime( 861): at dalvik.system.NativeStart.main(Native Method) W/ActivityManager( 123): Force finishing activity com.andrWow.wCraftArmory/.Armory

Here is the code around line 150 - The second line is line 150:

PlayerCharacter toon = worker.getToons().get(latestToon[0] + "&" + latestToon[1]); 
LinkedHashMap<String, LinkedHashMap<String, String>> bM = toon.getCategoryMap("baseStats");

It only gets this far if the result of assigning "toon" is not going to be null. The result of getCategoryMap with that key also shouldn't be null because it's pretty much hardcoded to adding a value with that key when it is created. getCategoryMap is a getter which checks the HashMap contains that key, if it doesn't, it would give an error into the system.out which isn't there.

Solved edit:

Thanks for your help everyone. I really didn't think it was a fault with the code because I knew it worked on the emulator and I had it running once on the phone too but it turns out it was a fault with my code. After getting FroYo, I set it up which included adding a new keyboard which automatically changed the case of the first letter so it was a matter of me not handling upper/lower cases properly - a silly mistake.

Thanks for your time, really appreciated!

1

There are 1 answers

1
Cheryl Simon On

Well, the obvious answer is that PlayerCharacter toon = worker.getToons().get(latestToon[0] + "&" + latestToon[1]); is returning null.

To figure out exactly why you can break it down into a few steps. What does latestToon[0] + "&" + latestToon[1] give you? Is it what you expect? I assume getToons() returns a map of some sort? What are the contents of it?