我最近从Eclipse升级到Android Studio ......
我将我的应用程序导入Android Studio,当我尝试通过ADB运行我的应用程序时,我的应用程序崩溃..
我删除了actionBar.setDisplayHomeAsUpEnabled(true);从一项活动和那项活动没有崩溃..
当我使用Eclipse时,我没有遇到此错误...
这是Logcat日志:
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test.test/com.test.test.MainActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2306)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2358)
at android.app.ActivityThread.access$600(ActivityThread.java:156)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1340)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:153)
at android.app.ActivityThread.main(ActivityThread.java:5299)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.test.test.MainActivity.onCreate(MainActivity.java:33)
at android.app.Activity.performCreate(Activity.java:5122)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2270)
在主要活动的第33行我将setDisplayHomeAsUpEnabled设置为True ..
主要活动的主题未设置为Theme.NoTitleBar ...
编辑:我尝试导入更多应用但我遇到了同样的错误...所有使用Eclipse的应用程序..
编辑:代码:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true); // Line 33