-1

这是日志猫。请帮忙

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

您的错误消息显示“NullPointerException”,它似乎是onCreate()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 回答