我已将我的应用程序上传到 Google Play,经过几次更新后,我收到了这样的错误
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.wipeout.simplegame/com.wipeout.simplegame.MainMenu}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3687)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.wipeout.simplegame.screen.MainMenu.onCreate(MainMenu.java:238)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
... 11 more
这是我的 MainMenu.java
private ImageView advertButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_menu);
advertButton = (ImageView) findViewById(R.id.advertOffButton);
advertButton.setOnClickListener(new OnClickListener() { //line 238
@Override
public void onClick(View v) {
if (mHelper != null) {
mHelper.flagEndAsync();
try {
mHelper.launchPurchaseFlow(MainMenu.this, SKU_PREMIUM, RC_REQUEST, mPurchaseFinishedListener, "");
} catch (IllegalStateException ex) {
}
}
}
});
}
我flagEndAsync()
在 IabHelper 中设置为公众,因为我看到这对某人有帮助,但我的问题仍然存在。我从谷歌开发者网站复制的应用计费中的整个代码,所以我不知道问题出在哪里。对我和少数测试帐户来说,一切都很好,但有些人有问题。