0

This apk is my recent update in production without proguard obfuscation or any optimization. Just in case so someone don't suggest it may be proguard related. However, I recently compiled with API 20: Android 4.4 Kitkat wear and set my target as API 21: L Preview. Eclipse compiled it successfully. I don't know if this could be a problem. I'm not sure if there are devices running on the L Preview yet. According to my google crash report all the devices that crashed where devices running on Android 4.4. This affected only less than 1% of my Android 4.4 installs. It stops working when the affected users try to open the app.

Below is the stack trace. Does anyone have any suggestions on how to fix this? Thanks.

    java.lang.NullPointerException
    at com.example.myproject.MainActivity$2.onItemClick(MainActivity.java:189)
    at android.widget.AdapterView.performItemClick(AdapterView.java:308)
    at android.widget.AbsListView.performItemClick(AbsListView.java:1495)
    at android.widget.AbsListView$PerformClick.run(AbsListView.java:3453)
    at android.widget.AbsListView$3.run(AbsListView.java:4816)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:146)
    at android.app.ActivityThread.main(ActivityThread.java:5487)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
    at dalvik.system.NativeStart.main(Native Method)

Here are the lines included in the stack trace:

Lines 188-191 are:

SharedPreferences.Editor editor = getSharedPreferences("settings", 0).edit();
editor.putString("lastKnownLatitude", String.valueOf(mCurrentLocation.getLatitude()));
editor.putString("lastKnownLongitude", String.valueOf(mCurrentLocation.getLongitude()));
editor.commit();

The lines are within listview.setOnItemClickListener and after editor.commit it starts a new activity.

Michael Yaworski
  • 13,410
  • 19
  • 69
  • 97
user3144836
  • 4,060
  • 3
  • 27
  • 27
  • 1
    possible duplicate of [Unfortunately MyApp has stopped. How can I solve this?](http://stackoverflow.com/questions/23353173/unfortunately-myapp-has-stopped-how-can-i-solve-this) – panini Jul 22 '14 at 01:09
  • @panini No... that question describes how to find the stack trace. He has his posted. – Michael Yaworski Jul 22 '14 at 01:13
  • 1
    And what **is** on line 189 of your `MainActivity.java`? – 323go Jul 22 '14 at 01:14
  • @mikeyaworski the answer also links to [this answer](http://stackoverflow.com/questions/3988788/what-is-a-stack-trace-and-how-can-i-use-it-to-debug-my-application-errors) which describes what to do with the stack trace. as it is, the stack trace posted doesn't help as we have no idea what MainActivity.java looks like. – panini Jul 22 '14 at 01:17
  • @mikeyaworski Thanks but for legal reasons I may not be able to post the source. However the MainActivity.java uses google fused location services and has a simple listView. There's nothing complex and works for 99.5% of other devices – user3144836 Jul 22 '14 at 01:22
  • @panini How can this be a duplicate when It's a specific stack trace question – user3144836 Jul 22 '14 at 01:25
  • @panini I saw that. First of all, you should link to that question if you think this is a duplicate of that. Not the question in between these "duplicates". And secondly, this question is supposed to be about the Android 4.4 thing (I think). – Michael Yaworski Jul 22 '14 at 01:26
  • @user3144836 Your stack trace is very easy to read. On line 189 of your MainActivity.java, you are running into a NullPointerException. The question is *why*? Is it because of Android 4.4? But still, your question could be a duplicate of that if it was only about the stack trace. Reading the stack trace is a duplicate even if it's only your own stack trace. But this question isn't entirely a duplicate. – Michael Yaworski Jul 22 '14 at 01:27
  • 2
    If you can't post the code, all we can do is tell you to learn how to read the stack trace. – Kevin Krumwiede Jul 22 '14 at 01:31
  • @323go Lines 188-191 is: SharedPreferences.Editor editor = getSharedPreferences("settings", 0).edit(); editor.putString("lastKnownLatitude", String.valueOf(mCurrentLocation.getLatitude())); editor.putString("lastKnownLongitude", String.valueOf(mCurrentLocation.getLongitude())); editor.commit(); withing listview.setOnItemClickListener and after editor.commit it starts a new activity – user3144836 Jul 22 '14 at 01:33
  • 1
    Looks like `mCurrentLocation` is null. Check that out. – Michael Yaworski Jul 22 '14 at 01:43
  • Thanks I'll make some changes to my code on line 189. I don't have to use SharedPreferences.Editor. I'll get around it. Thanks for your suggestions. I'll see what happens after I send in a new update to production. – user3144836 Jul 22 '14 at 01:45
  • SharedPreferences isn't your problem. It's location. – 323go Jul 22 '14 at 12:55

0 Answers0