该应用程序已意外停止Android代码

时间:2015-11-10 18:50:23

标签: android

当我运行Android应用程序时,我从Eclipse中的模拟器中收到以下错误...

"应用程序意外停止。请再试一次"

Eclipse中的项目文件夹中没有出现错误图标。我已经尝试过......

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

     mDrawerList = (ListView) findViewById(R.id.navList);
        mDrawerLayout = (DrawerLayout)findViewById(R.id.drawer_layout);
        mActivityTitle = getTitle().toString();

       addDrawerItems();
        setupDrawer();

        getActionBar().setDisplayHomeAsUpEnabled(true);
        getActionBar().setHomeButtonEnabled(true);

}




  Lcom/example/navigationdrawerexample/MainActivity;.getActionBar ()Landroid/app/ActionBar;
    11-10 22:14:13.201: D/dalvikvm(300): VFY: replacing opcode 0x6e at 0x0002
    11-10 22:14:13.201: D/dalvikvm(300): VFY: dead code 0x0005-000b in Lcom/example/navigationdrawerexample/MainActivity;.setTitle (Ljava/lang/CharSequence;)V
    11-10 22:14:13.451: I/dalvikvm(300): Could not find method com.example.navigationdrawerexample.MainActivity.getActionBar, referenced from method com.example.navigationdrawerexample.MainActivity$1.onDrawerClosed
    11-10 22:14:13.451: W/dalvikvm(300): VFY: unable to resolve virtual method 5112: Lcom/example/navigationdrawerexample/MainActivity;.getActionBar 

    ()Landroid/app/ActionBar;
    11-10 22:14:13.451: D/dalvikvm(300): VFY: replacing opcode 0x6e at 0x0005
    11-10 22:14:13.451: D/dalvikvm(300): VFY: dead code 0x0008-0012 in Lcom/example/navigationdrawerexample/MainActivity$1;.onDrawerClosed (Landroid/view/View;)V
    11-10 22:14:13.451: I/dalvikvm(300): Could not find method com.example.navigationdrawerexample.MainActivity.getActionBar, referenced from method com.example.navigationdrawerexample.MainActivity$1.onDrawerOpened
    11-10 22:14:13.451: W/dalvikvm(300): VFY: unable to resolve virtual method 5112: Lcom/example/navigationdrawerexample/MainActivity;.getActionBar ()Landroid/app/ActionBar;
    11-10 22:14:13.451: D/dalvikvm(300): VFY: replacing opcode 0x6e at 0x0005
    11-10 22:14:13.451: D/dalvikvm(300): VFY: dead code 0x0008-0012 in Lcom/example/navigationdrawerexample/MainActivity$1;.onDrawerOpened (Landroid/view/View;)V
    11-10 22:14:13.491: D/AndroidRuntime(300): Shutting down VM
    11-10 22:14:13.491: W/dalvikvm(300): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
    11-10 22:14:13.531: E/AndroidRuntime(300): FATAL EXCEPTION: main
    11-10 22:14:13.531: E/AndroidRuntime(300): java.lang.NoSuchMethodError: com.example.navigationdrawerexample.MainActivity.getActionBar
    11-10 22:14:13.531: E/AndroidRuntime(300):  at com.example.navigationdrawerexample.MainActivity.onCreate(MainActivity.java:91)
    11-10 22:14:13.531: E/AndroidRuntime(300):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    11-10 22:14:13.531: E/AndroidRuntime(300):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
    11-10 22:14:13.531: E/AndroidRuntime(300):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
    11-10 22:14:13.531: E/AndroidRuntime(300):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
    11-10 22:14:13.531: E/AndroidRuntime(300):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
    11-10 22:14:13.531: E/AndroidRuntime(300):  at android.os.Handler.dispatchMessage(Handler.java:99)
    11-10 22:14:13.531: E/AndroidRuntime(300):  at android.os.Looper.loop(Looper.java:123)
    11-10 22:14:13.531: E/AndroidRuntime(300):  at android.app.ActivityThread.main(ActivityThread.java:4627)
    11-10 22:14:13.531: E/AndroidRuntime(300):  at java.lang.reflect.Method.invokeNative(Native Method)
    11-10 22:14:13.531: E/AndroidRuntime(300):  at java.lang.reflect.Method.invoke(Method.java:521)
    11-10 22:14:13.531: E/AndroidRuntime(300):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    11-10 22:14:13.531: E/AndroidRuntime(300):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    11-10 22:14:13.531: E/AndroidRuntime(300):  at dalvik.system.NativeStart.main(Native Method)
    11-10 22:14:43.583: I/Process(300): Sending signal. PID: 300 SIG: 9
    11-10 22:14:49.780: I/dalvikvm(309): Could not find method com.example.navigationdrawerexample.MainActivity.getFragmentManager, referenced from method com.example.navigationdrawerexample.MainActivity.selectItem
    11-10 22:14:49.790: W/dalvikvm(309): VFY: unable to resolve virtual method 5113: Lcom/example/navigationdrawerexample/MainActivity;.getFragmentManager ()Landroid/app/FragmentManager;
    11-10 22:14:49.801: D/dalvikvm(309): VFY: replacing opcode 0x6e at 0x0006
    11-10 22:14:49.820: W/dalvikvm(309): Unable to resolve superclass of Lcom/example/navigationdrawerexample/CreateFragment; (12)
    11-10 22:14:49.820: W/dalvikvm(309): Link of class 'Lcom/example/navigationdrawerexample/CreateFragment;' failed
    11-10 22:14:49.840: E/dalvikvm(309): Could not find class 'com.example.navigationdrawerexample.CreateFragment', referenced from method com.example.navigationdrawerexample.MainActivity.selectItem
    11-10 22:14:49.840: W/dalvikvm(309): VFY: unable to resolve new-instance 716 (Lcom/example/navigationdrawerexample/CreateFragment;) in Lcom/example/navigationdrawerexample/MainActivity;
    11-10 22:14:49.850: D/dalvikvm(309): VFY: replacing opcode 0x22 at 0x0032
    11-10 22:14:49.880: W/dalvikvm(309): Unable to resolve superclass of Lcom/example/navigationdrawerexample/ReadFragment; (12)
    11-10 22:14:49.880: W/dalvikvm(309): Link of class 'Lcom/example/navigationdrawerexample/ReadFragment;' failed
    11-10 22:14:49.891: E/dalvikvm(309): Could not find class 'com.example.navigationdrawerexample.ReadFragment', referenced from method com.example.navigationdrawerexample.MainActivity.selectItem
    11-10 22:14:49.900: W/dalvikvm(309): VFY: unable to resolve new-instance 733 (Lcom/example/navigationdrawerexample/ReadFragment;) in Lcom/example/navigationdrawerexample/MainActivity;
    11-10 22:14:49.910: D/dalvikvm(309): VFY: replacing opcode 0x22 at 0x0038
    11-10 22:14:49.920: W/dalvikvm(309): Unable to resolve superclass of Lcom/example/navigationdrawerexample/HelpFragment; (12)
    11-10 22:14:49.920: W/dalvikvm(309): Link of class 'Lcom/example/navigationdrawerexample/HelpFragment;' failed
    11-10 22:14:49.941: E/dalvikvm(309): Could not find class 'com.example.navigationdrawerexample.HelpFragment', referenced from method com.example.navigationdrawerexample.MainActivity.selectItem
    11-10 22:14:49.941: W/dalvikvm(309): VFY: unable to resolve new-instance 718 (Lcom/example/navigationdrawerexample/HelpFragment;) in Lcom/example/navigationdrawerexample/MainActivity;
    11-10 22:14:49.941: D/dalvikvm(309): VFY: replacing opcode 0x22 at 0x003e
    11-10 22:14:49.960: D/dalvikvm(309): VFY: dead code 0x0009-0030 in Lcom/example/navigationdrawerexample/MainActivity;.selectItem (I)V
    11-10 22:14:49.960: D/dalvikvm(309): VFY: dead code 0x0034-0037 in Lcom/example/navigationdrawerexample/MainActivity;.selectItem (I)V
    11-10 22:14:49.971: D/dalvikvm(309): VFY: dead code 0x003a-003d in Lcom/example/navigationdrawerexample/MainActivity;.selectItem (I)V
    11-10 22:14:49.971: D/dalvikvm(309): VFY: dead code 0x0040-0043 in Lcom/example/navigationdrawerexample/MainActivity;.selectItem (I)V
    11-10 22:14:50.040: I/dalvikvm(309): Could not find method com.example.navigationdrawerexample.MainActivity.getActionBar, referenced from method com.example.navigationdrawerexample.MainActivity.onCreate
    11-10 22:14:50.040: W/dalvikvm(309): VFY: unable to resolve virtual method 5112: Lcom/example/navigationdrawerexample/MainActivity;.getActionBar ()Landroid/app/ActionBar;
    11-10 22:14:50.051: D/dalvikvm(309): VFY: replacing opcode 0x6e at 0x0095
    11-10 22:14:50.061: D/dalvikvm(309): VFY: dead code 0x0098-00a8 in Lcom/example/navigationdrawerexample/MainActivity;.onCreate (Landroid/os/Bundle;)V
    11-10 22:14:50.081: I/dalvikvm(309): Could not find method com.example.navigationdrawerexample.MainActivity.getActionBar, referenced from method com.example.navigationdrawerexample.MainActivity.setTitle
    11-10 22:14:50.081: W/dalvikvm(309): VFY: unable to resolve virtual method 5112: Lcom/example/navigationdrawerexample/MainActivity;.getActionBar ()Landroid/app/ActionBar;
    11-10 22:14:50.101: D/dalvikvm(309): VFY: replacing opcode 0x6e at 0x0002
    11-10 22:14:50.101: D/dalvikvm(309): VFY: dead code 0x0005-000b in Lcom/example/navigationdrawerexample/MainActivity;.setTitle (Ljava/lang/CharSequence;)V
    11-10 22:14:50.351: I/dalvikvm(309): Could not find method com.example.navigationdrawerexample.MainActivity.getActionBar, referenced from method com.example.navigationdrawerexample.MainActivity$1.onDrawerClosed
    11-10 22:14:50.351: W/dalvikvm(309): VFY: unable to resolve virtual method 5112: Lcom/example/navigationdrawerexample/MainActivity;.getActionBar ()Landroid/app/ActionBar;
    11-10 22:14:50.361: D/dalvikvm(309): VFY: replacing opcode 0x6e at 0x0005
    11-10 22:14:50.361: D/dalvikvm(309): VFY: dead code 0x0008-0012 in Lcom/example/navigationdrawerexample/MainActivity$1;.onDrawerClosed (Landroid/view/View;)V
    11-10 22:14:50.381: I/dalvikvm(309): Could not find method com.example.navigationdrawerexample.MainActivity.getActionBar, referenced from method com.example.navigationdrawerexample.MainActivity$1.onDrawerOpened
    11-10 22:14:50.381: W/dalvikvm(309): VFY: unable to resolve virtual method 5112: Lcom/example/navigationdrawerexample/MainActivity;.getActionBar ()Landroid/app/ActionBar;
    11-10 22:14:50.390: D/dalvikvm(309): VFY: replacing opcode 0x6e at 0x0005
    11-10 22:14:50.390: D/dalvikvm(309): VFY: dead code 0x0008-0012 in Lcom/example/navigationdrawerexample/MainActivity$1;.onDrawerOpened (Landroid/view/View;)V
    11-10 22:14:50.461: D/AndroidRuntime(309): Shutting down VM
    11-10 22:14:50.461: W/dalvikvm(309): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
    11-10 22:14:50.501: E/AndroidRuntime(309): FATAL EXCEPTION: main
    11-10 22:14:50.501: E/AndroidRuntime(309): java.lang.NoSuchMethodError: com.example.navigationdrawerexample.MainActivity.getActionBar
    11-10 22:14:50.501: E/AndroidRuntime(309):  at com.example.navigationdrawerexample.MainActivity.onCreate(MainActivity.java:91)
    11-10 22:14:50.501: E/AndroidRuntime(309):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    11-10 22:14:50.501: E/AndroidRuntime(309):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
    11-10 22:14:50.501: E/AndroidRuntime(309):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
    11-10 22:14:50.501: E/AndroidRuntime(309):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
    11-10 22:14:50.501: E/AndroidRuntime(309):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
    11-10 22:14:50.501: E/AndroidRuntime(309):  at android.os.Handler.dispatchMessage(Handler.java:99)
    11-10 22:14:50.501: E/AndroidRuntime(309):  at android.os.Looper.loop(Looper.java:123)
    11-10 22:14:50.501: E/AndroidRuntime(309):  at android.app.ActivityThread.main(ActivityThread.java:4627)
    11-10 22:14:50.501: E/AndroidRuntime(309):  at java.lang.reflect.Method.invokeNative(Native Method)
    11-10 22:14:50.501: E/AndroidRuntime(309):  at java.lang.reflect.Method.invoke(Method.java:521)
    11-10 22:14:50.501: E/AndroidRuntime(309):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    11-10 22:14:50.501: E/AndroidRuntime(309):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
    11-10 22:14:50.501: E/AndroidRuntime(309):  at dalvik.system.NativeStart.main(Native Method)

1 个答案:

答案 0 :(得分:0)

如果您使用的是支持v7库,请尝试使用 getSupportActionBar()