当我运行我的应用程序时,我正在模拟器上意外停止进程。这是我的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
答案 0 :(得分: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.java:16)
您将看到首先在您的活动第16行中抛出NullPointerException
。
如果您需要更多帮助,请发布您的第一个活动的代码。
答案 1 :(得分: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 android:name=".firstl" />