0

当我运行我的应用程序时,我在模拟器上意外停止了进程。这是我的 logcat 详细信息:

06-30 15:09:46.126: D/dalvikvm(520): GC_EXTERNAL_ALLOC freed 46K, 53% free 2551K/5379K, external 1625K/2137K, paused 72ms
06-30 15:09:50.146: D/dalvikvm(520): GC_EXTERNAL_ALLOC freed 11K, 53% free 2580K/5379K, external 4697K/5866K, paused 51ms
06-30 15:09:51.196: D/AndroidRuntime(520): Shutting down VM
06-30 15:09:51.196: W/dalvikvm(520): threadid=1: thread exiting with uncaught exception (group=0x40015560)
06-30 15:09:51.217: E/AndroidRuntime(520): FATAL EXCEPTION: main
06-30 15:09:51.217: E/AndroidRuntime(520): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mesha.firstand/com.mesha.firstand.firstl}: java.lang.NullPointerException
06-30 15:09:51.217: E/AndroidRuntime(520):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
06-30 15:09:51.217: E/AndroidRuntime(520):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
06-30 15:09:51.217: E/AndroidRuntime(520):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
06-30 15:09:51.217: E/AndroidRuntime(520):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
06-30 15:09:51.217: E/AndroidRuntime(520):  at android.os.Handler.dispatchMessage(Handler.java:99)
06-30 15:09:51.217: E/AndroidRuntime(520):  at android.os.Looper.loop(Looper.java:123)
06-30 15:09:51.217: E/AndroidRuntime(520):  at android.app.ActivityThread.main(ActivityThread.java:3683)
06-30 15:09:51.217: E/AndroidRuntime(520):  at java.lang.reflect.Method.invokeNative(Native Method)
06-30 15:09:51.217: E/AndroidRuntime(520):  at java.lang.reflect.Method.invoke(Method.java:507)
06-30 15:09:51.217: E/AndroidRuntime(520):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-30 15:09:51.217: E/AndroidRuntime(520):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-30 15:09:51.217: E/AndroidRuntime(520):  at dalvik.system.NativeStart.main(Native Method)
06-30 15:09:51.217: E/AndroidRuntime(520): Caused by: java.lang.NullPointerException
06-30 15:09:51.217: E/AndroidRuntime(520):  at com.mesha.firstand.firstl.onCreate(firstl.java:16)
06-30 15:09:51.217: E/AndroidRuntime(520):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-30 15:09:51.217: E/AndroidRuntime(520):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
06-30 15:09:51.217: E/AndroidRuntime(520):  ... 11 more
06-30 15:09:54.516: I/Process(520): Sending signal. PID: 520 SIG: 9
06-30 15:17:01.117: D/dalvikvm(539): GC_EXTERNAL_ALLOC freed 48K, 53% free 2551K/5379K, external 1625K/2137K, paused 52ms
06-30 15:17:03.237: D/dalvikvm(539): GC_EXTERNAL_ALLOC freed 11K, 53% free 2580K/5379K, external 4697K/5866K, paused 52ms
06-30 15:17:04.327: D/AndroidRuntime(539): Shutting down VM
06-30 15:17:04.327: W/dalvikvm(539): threadid=1: thread exiting with uncaught exception (group=0x40015560)
06-30 15:17:04.346: E/AndroidRuntime(539): FATAL EXCEPTION: main
06-30 15:17:04.346: E/AndroidRuntime(539): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mesha.firstand/com.mesha.firstand.firstl}: java.lang.NullPointerException
06-30 15:17:04.346: E/AndroidRuntime(539):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
06-30 15:17:04.346: E/AndroidRuntime(539):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
06-30 15:17:04.346: E/AndroidRuntime(539):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
06-30 15:17:04.346: E/AndroidRuntime(539):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
06-30 15:17:04.346: E/AndroidRuntime(539):  at android.os.Handler.dispatchMessage(Handler.java:99)
06-30 15:17:04.346: E/AndroidRuntime(539):  at android.os.Looper.loop(Looper.java:123)
06-30 15:17:04.346: E/AndroidRuntime(539):  at android.app.ActivityThread.main(ActivityThread.java:3683)
06-30 15:17:04.346: E/AndroidRuntime(539):  at java.lang.reflect.Method.invokeNative(Native Method)
06-30 15:17:04.346: E/AndroidRuntime(539):  at java.lang.reflect.Method.invoke(Method.java:507)
06-30 15:17:04.346: E/AndroidRuntime(539):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-30 15:17:04.346: E/AndroidRuntime(539):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-30 15:17:04.346: E/AndroidRuntime(539):  at dalvik.system.NativeStart.main(Native Method)
06-30 15:17:04.346: E/AndroidRuntime(539): Caused by: java.lang.NullPointerException
06-30 15:17:04.346: E/AndroidRuntime(539):  at com.mesha.firstand.firstl.onCreate(firstl.java:16)
06-30 15:17:04.346: E/AndroidRuntime(539):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-30 15:17:04.346: E/AndroidRuntime(539):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
06-30 15:17:04.346: E/AndroidRuntime(539):  ... 11 more
06-30 15:17:08.717: I/Process(539): Sending signal. PID: 539 SIG: 9
4

2 回答 2

0

看着日志

15:17:04.346: E/AndroidRuntime(539): 由: java.lang.NullPointerException 06-30 15:17:04.346: E/AndroidRuntime(539): at com.mesha.firstand.firstl.onCreate(firstl.爪哇:16)

您将看到 aNullPointerException在您的活动 firstl 的第 16 行中抛出。

如果您需要更多帮助,请发布您的 firstl 活动代码。

于 2012-06-30T10:14:50.010 回答
0

在看到你的 logcat 之后,这些可能是可能的

案例1:确保您设置正确的布局:

public class firstl extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // The activity is being created.
          setContentView(R.layout.main);//MAKE SURE YOU ARE SETTING RIGHT LAYOUT
    }

案例 2:确保您使用正确的 id 来访问代码中定义的 xml 布局中的视图

案例 3:确保您在 Manifest.xml 中使用正确的名称注册 Activity:

<Activity android:name=".firstl" />
于 2012-06-30T10:16:14.807 回答