我已经在 google play 我的应用程序上发布了。谷歌告诉我,我的应用程序在用户使用时崩溃了 2 次。我测试了我的应用程序很多次,但我从来没有得到那个错误,而且我不知道如何模拟那个错误。
java.lang.RuntimeException: Unable to resume activity {com.mdp.slotmachine/com.mdp.slotmachine.CoverActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2444)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2472)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1986)
at android.app.ActivityThread.access$600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4429)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at android.app.ContextImpl.startService(ContextImpl.java:1088)
at android.content.ContextWrapper.startService(ContextWrapper.java:359)
at com.mdp.slotmachine.CoverActivity.onResume(Unknown Source)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1154)
at android.app.Activity.performResume(Activity.java:4539)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2434)
... 12 more
错误似乎在 CoverActivity 类中,在 onResume 方法中。如您所见,我在 onResume 方法中没有做任何事情。
@Override
protected void onResume() {
super.onPause();
//check if i'm publishing the app on samsung store
if(MainActivity.samsung){
// here i check if my app was properly downloaded from samsung store by using Zirconia.
// BUT I NEVER GET HERE; BECAUSE THE PREVIUOS VARIABLE (MainActivity.samsung) IS ALWAYS FALSE.
if(!MainActivity.licensaSamsung){
finish();
}
}
}