以下は私のコードです。「addDebtor」ボタンをクリックすると、次のエラーが表示されます。アプリケーション Debt Tracker (プロセス biz.midl.debttracker) が予期せず停止しました。もう一度やり直してください。
IDE にエラーが見つかりません。ボタンの名前を確認したところ、一致しました。他のアクティビティの名前を確認したところ、それも一致しました。
何か案は?
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button getAnswerButton = (Button) findViewById(R.id.addDebtor);
getAnswerButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(MainActivity.this, addDebt.class));
}
});
}
}
Logcat エラーは次のとおりです。
09-12 06:03:49.744: D/AndroidRuntime(246): Shutting down VM
09-12 06:03:49.744: W/dalvikvm(246): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
09-12 06:03:49.765: E/AndroidRuntime(246): FATAL EXCEPTION: main
09-12 06:03:49.765: E/AndroidRuntime(246): android.content.ActivityNotFoundException: Unable to find explicit activity class {biz.midl.debttracker/biz.midl.debttracker.addDebt}; have you declared this activity in your AndroidManifest.xml?
09-12 06:03:49.765: E/AndroidRuntime(246): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
09-12 06:03:49.765: E/AndroidRuntime(246): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
09-12 06:03:49.765: E/AndroidRuntime(246): at android.app.Activity.startActivityForResult(Activity.java:2817)
09-12 06:03:49.765: E/AndroidRuntime(246): at android.app.Activity.startActivity(Activity.java:2923)
09-12 06:03:49.765: E/AndroidRuntime(246): at biz.midl.debttracker.MainActivity$1.onClick(MainActivity.java:22)
09-12 06:03:49.765: E/AndroidRuntime(246): at android.view.View.performClick(View.java:2408)
09-12 06:03:49.765: E/AndroidRuntime(246): at android.view.View$PerformClick.run(View.java:8816)
09-12 06:03:49.765: E/AndroidRuntime(246): at android.os.Handler.handleCallback(Handler.java:587)
09-12 06:03:49.765: E/AndroidRuntime(246): at android.os.Handler.dispatchMessage(Handler.java:92)
09-12 06:03:49.765: E/AndroidRuntime(246): at android.os.Looper.loop(Looper.java:123)
09-12 06:03:49.765: E/AndroidRuntime(246): at android.app.ActivityThread.main(ActivityThread.java:4627)
09-12 06:03:49.765: E/AndroidRuntime(246): at java.lang.reflect.Method.invokeNative(Native Method)
09-12 06:03:49.765: E/AndroidRuntime(246): at java.lang.reflect.Method.invoke(Method.java:521)
09-12 06:03:49.765: E/AndroidRuntime(246): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-12 06:03:49.765: E/AndroidRuntime(246): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-12 06:03:49.765: E/AndroidRuntime(246): at dalvik.system.NativeStart.main(Native Method)
09-12 06:08:54.834: D/AndroidRuntime(277): Shutting down VM
09-12 06:08:54.834: W/dalvikvm(277): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
09-12 06:08:54.845: E/AndroidRuntime(277): FATAL EXCEPTION: main
09-12 06:08:54.845: E/AndroidRuntime(277): android.content.ActivityNotFoundException: Unable to find explicit activity class {biz.midl.debttracker/biz.midl.debttracker.addDebt}; have you declared this activity in your AndroidManifest.xml?
09-12 06:08:54.845: E/AndroidRuntime(277): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
09-12 06:08:54.845: E/AndroidRuntime(277): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
09-12 06:08:54.845: E/AndroidRuntime(277): at android.app.Activity.startActivityForResult(Activity.java:2817)
09-12 06:08:54.845: E/AndroidRuntime(277): at android.app.Activity.startActivity(Activity.java:2923)
09-12 06:08:54.845: E/AndroidRuntime(277): at biz.midl.debttracker.MainActivity$1.onClick(MainActivity.java:22)
09-12 06:08:54.845: E/AndroidRuntime(277): at android.view.View.performClick(View.java:2408)
09-12 06:08:54.845: E/AndroidRuntime(277): at android.view.View$PerformClick.run(View.java:8816)
09-12 06:08:54.845: E/AndroidRuntime(277): at android.os.Handler.handleCallback(Handler.java:587)
09-12 06:08:54.845: E/AndroidRuntime(277): at android.os.Handler.dispatchMessage(Handler.java:92)
09-12 06:08:54.845: E/AndroidRuntime(277): at android.os.Looper.loop(Looper.java:123)
09-12 06:08:54.845: E/AndroidRuntime(277): at android.app.ActivityThread.main(ActivityThread.java:4627)
09-12 06:08:54.845: E/AndroidRuntime(277): at java.lang.reflect.Method.invokeNative(Native Method)
09-12 06:08:54.845: E/AndroidRuntime(277): at java.lang.reflect.Method.invoke(Method.java:521)
09-12 06:08:54.845: E/AndroidRuntime(277): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-12 06:08:54.845: E/AndroidRuntime(277): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-12 06:08:54.845: E/AndroidRuntime(277): at dalvik.system.NativeStart.main(Native Method)