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): com.mesha.firstand.firstl.onCreate(firstl.ジャワ:16)

NullPointerExceptionまず、アクティビティの 16 行目にa がスローされていることがわかります。

さらにヘルプが必要な場合は、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: xml レイアウトで定義されているように、コードでアクセスするビューに正しい ID を使用していることを確認してください

ケース 3: Manifest.xml に正しい名前で Activity を登録していることを確認します。

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