Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Activity.getSharedPreferences(java.lang.String, int)' on a null object reference #129

Open
chiaberry opened this issue Jun 10, 2019 · 1 comment

Comments

@chiaberry
Copy link
Contributor

I've encountered some weirdness on Android once my app has been running for a while, I am not sure if theres a bug in my app that is contributing to the error or if the error is what is causing the weirdness.

After my app has been open for a while and I've gone to use other apps, when I come back to my app it is stuck loading. When I close the app and open it again, everything loads fine. (And I am still logged into the package/Spotify.) I finally got some logs and this was near the beginning:

E/AndroidRuntime(30413): java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.SharedPreferences android.app.Activity.getSharedPreferences(java.lang.String, int)' on a null object reference.

and then:

Console 14:56:44 E/AndroidRuntime(30413): at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:106)
Console 14:56:44 E/AndroidRuntime(30413): at com.lufinkey.react.spotify.HTTPRequest.deliverResponse(HTTPRequest.java:39)
Console 14:56:44 E/AndroidRuntime(30413): at com.lufinkey.react.spotify.HTTPRequest.deliverResponse(HTTPRequest.java:88)
Console 14:56:44 E/AndroidRuntime(30413): at com.lufinkey.react.spotify.Utils$1.onResponse(Utils.java:107)
Console 14:56:44 E/AndroidRuntime(30413): at com.lufinkey.react.spotify.Completion.resolve(Completion.java:13)
Console 14:56:44 E/AndroidRuntime(30413): at com.lufinkey.react.spotify.Auth$3.onComplete(Auth.java:313)
Console 14:56:44 E/AndroidRuntime(30413): at com.lufinkey.react.spotify.Auth$3.onComplete(Auth.java:329)
Console 14:56:44 E/AndroidRuntime(30413): at com.lufinkey.react.spotify.Completion.resolve(Completion.java:13)
Console 14:56:44 E/AndroidRuntime(30413): at com.lufinkey.react.spotify.Auth$2.onComplete(Auth.java:222)
Console 14:56:44 E/AndroidRuntime(30413): at com.lufinkey.react.spotify.Auth$2.onComplete(Auth.java:237)
Console 14:56:44 E/AndroidRuntime(30413): at com.lufinkey.react.spotify.Auth.save(Auth.java:70)

So it seems that it only crashes like this when the app is in background and I bring it back up after time has passed. If I put it in background and bring it back up within the next few minutes, its fine. I'll try putting it in background and opening it again after an hour and see if thats when it crashes.

I have the Spotify app on my phone, it's what logs me in to the spotify library.
My phone is a Pixel 3, Android 9. Let me know what other information would be useful.

react-native: 0.59.3
rn-spotify-sdk: 1.2.6

@chiaberry
Copy link
Contributor Author

Screenshot_20190617-132224

I got it to happen when I was debugging on my device. Has anyone else encountered this error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant