-1

これがlogcatです。助けてください

04-30 11:52:45.716: E/AndroidRuntime(1430): FATAL EXCEPTION: main
04-30 11:52:45.716: E/AndroidRuntime(1430): java.lang.RuntimeException: Unable to start activity ComponentInfo{my.calc/my.calc.CalcActivity}: java.lang.NullPointerException
04-30 11:52:45.716: E/AndroidRuntime(1430):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
04-30 11:52:45.716: E/AndroidRuntime(1430):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
04-30 11:52:45.716: E/AndroidRuntime(1430):     at android.app.ActivityThread.access$600(ActivityThread.java:123)
04-30 11:52:45.716: E/AndroidRuntime(1430):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
04-30 11:52:45.716: E/AndroidRuntime(1430):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-30 11:52:45.716: E/AndroidRuntime(1430):     at android.os.Looper.loop(Looper.java:137)
04-30 11:52:45.716: E/AndroidRuntime(1430):     at android.app.ActivityThread.main(ActivityThread.java:4424)
04-30 11:52:45.716: E/AndroidRuntime(1430):     at java.lang.reflect.Method.invokeNative(Native Method)
04-30 11:52:45.716: E/AndroidRuntime(1430):     at java.lang.reflect.Method.invoke(Method.java:511)
04-30 11:52:45.716: E/AndroidRuntime(1430):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-30 11:52:45.716: E/AndroidRuntime(1430):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-30 11:52:45.716: E/AndroidRuntime(1430):     at dalvik.system.NativeStart.main(Native Method)
04-30 11:52:45.716: E/AndroidRuntime(1430): Caused by: java.lang.NullPointerException
04-30 11:52:45.716: E/AndroidRuntime(1430):     at my.calc.CalcActivity.onCreate(CalcActivity.java:47)
04-30 11:52:45.716: E/AndroidRuntime(1430):     at android.app.Activity.performCreate(Activity.java:4465)
04-30 11:52:45.716: E/AndroidRuntime(1430):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
04-30 11:52:45.716: E/AndroidRuntime(1430):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
04-30 11:52:45.716: E/AndroidRuntime(1430):     ... 11 more
04-30 11:53:59.415: E/AndroidRuntime(1445): FATAL EXCEPTION: main
04-30 11:53:59.415: E/AndroidRuntime(1445): java.lang.RuntimeException: Unable to start activity ComponentInfo{my.calc/my.calc.CalcActivity}: java.lang.NullPointerException
04-30 11:53:59.415: E/AndroidRuntime(1445):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
04-30 11:53:59.415: E/AndroidRuntime(1445):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
04-30 11:53:59.415: E/AndroidRuntime(1445):     at android.app.ActivityThread.access$600(ActivityThread.java:123)
04-30 11:53:59.415: E/AndroidRuntime(1445):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
04-30 11:53:59.415: E/AndroidRuntime(1445):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-30 11:53:59.415: E/AndroidRuntime(1445):     at android.os.Looper.loop(Looper.java:137)
04-30 11:53:59.415: E/AndroidRuntime(1445):     at android.app.ActivityThread.main(ActivityThread.java:4424)
04-30 11:53:59.415: E/AndroidRuntime(1445):     at java.lang.reflect.Method.invokeNative(Native Method)
04-30 11:53:59.415: E/AndroidRuntime(1445):     at java.lang.reflect.Method.invoke(Method.java:511)
04-30 11:53:59.415: E/AndroidRuntime(1445):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-30 11:53:59.415: E/AndroidRuntime(1445):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-30 11:53:59.415: E/AndroidRuntime(1445):     at dalvik.system.NativeStart.main(Native Method)
04-30 11:53:59.415: E/AndroidRuntime(1445): Caused by: java.lang.NullPointerException
04-30 11:53:59.415: E/AndroidRuntime(1445):     at my.calc.CalcActivity.onCreate(CalcActivity.java:47)
04-30 11:53:59.415: E/AndroidRuntime(1445):     at android.app.Activity.performCreate(Activity.java:4465)
04-30 11:53:59.415: E/AndroidRuntime(1445):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
04-30 11:53:59.415: E/AndroidRuntime(1445):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
04-30 11:53:59.415: E/AndroidRuntime(1445):     ... 11 more
4

1 に答える 1

0

onCreate()エラーメッセージに「NullPointerException」と表示されますが、これは。のメソッド内の何かが原因であると思われますCalcActivity。次のように、そのクラスのコードの47行目に移動します。

04-30 11:53:59.415: E/AndroidRuntime(1445): Caused by: java.lang.NullPointerException
04-30 11:53:59.415: E/AndroidRuntime(1445):     at my.calc.CalcActivity.onCreate(CalcActivity.java:47)

まだ初期化されていないオブジェクト、または基本的に値を持つオブジェクトを呼び出さなかったことを確認してくださいnull。例えば、

List<String> strings;
strings.get(0); // you should have done something like this one first:
                // strings = new ArrayList<String>();
于 2012-08-03T12:50:15.923 に答える