小さなお子様向けの話し言葉付き無料アプリ画像スライダーをリリースしました。数週間前、最初のクラッシュ レポートを受け取りました。これはまれにしか発生しないようです (週に 1 回)。
レポートの状態: Splash.onCreate() の NullPointerException
スタック トレースに次のメッセージが表示されます。
java.lang.RuntimeException: Unable to start activity
java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
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:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at co.uk.musenuovo.michal.Splash.onCreate(Splash.java:18)
at android.app.Activity.performCreate(Activity.java:5008)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
スパッシュアクティビティの私のコード(画像を表示し、曲を5秒間再生する最初の画面):
import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
public class Splash extends Activity {
MediaPlayer ourSong;
@Override
protected void onCreate(Bundle ShowSplashPage) {
// TODO Auto-generated method stub
super.onCreate(ShowSplashPage);
setContentView(R.layout.splash);
ourSong = MediaPlayer.create(Splash.this, R.raw.xylophone_open);
ourSong.start();
Thread timer = new Thread() {
public void run() {
try{
sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
Intent openStartingPoint = new Intent("co.uk.musenuovo.michal.STARTINGPOINT");
startActivity(openStartingPoint);
}
}
};
timer.start();
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
ourSong.release();
finish();
}
}
エラーは、spash アクティビティの onstart を明確に示しています。これは、いくつかのライブラリをインポートするのを忘れたためですか? または、何かを割り当てるのを忘れましたか?私はJavaが初めてで、デバッグして問題を見つける方法がわかりません。私は多くのことを読みましたNullPointerException
が、これは非常に漠然としたエラーのようです。いつもお世話になっております。