简体   繁体   English

Android hello world无法正常工作

[英]Android hello world is not working

My logcat error and code is given below: 我的logcat错误和代码如下:

public class MainActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}

Logcat: Logcat:

08-15 11:42:43.735: D/AndroidRuntime(1864): Shutting down VM

08-15 11:42:43.735: W/dalvikvm(1864): threadid=1: thread exiting with uncaught exception (group=0xb1d54ce8)
08-15 11:42:43.755: E/AndroidRuntime(1864): FATAL EXCEPTION: main
08-15 11:42:43.755: E/AndroidRuntime(1864): Process: com.example.helloworld, PID: 1864
08-15 11:42:43.755: E/AndroidRuntime(1864): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.helloworld/com.example.helloworld.MainActivity}: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
08-15 11:42:43.755: E/AndroidRuntime(1864):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197)
08-15 11:42:43.755: E/AndroidRuntime(1864):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258)
08-15 11:42:43.755: E/AndroidRuntime(1864):     at android.app.ActivityThread.access$800(ActivityThread.java:138)
08-15 11:42:43.755: E/AndroidRuntime(1864):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
08-15 11:42:43.755: E/AndroidRuntime(1864):     at android.os.Handler.dispatchMessage(Handler.java:102)
08-15 11:42:43.755: E/AndroidRuntime(1864):     at android.os.Looper.loop(Looper.java:136)
08-15 11:42:43.755: E/AndroidRuntime(1864):     at android.app.ActivityThread.main(ActivityThread.java:5026)
08-15 11:42:43.755: E/AndroidRuntime(1864):     at java.lang.reflect.Method.invokeNative(Native Method)
08-15 11:42:43.755: E/AndroidRuntime(1864):     at java.lang.reflect.Method.invoke(Method.java:515)
08-15 11:42:43.755: E/AndroidRuntime(1864):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
08-15 11:42:43.755: E/AndroidRuntime(1864):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
08-15 11:42:43.755: E/AndroidRuntime(1864):     at dalvik.system.NativeStart.main(Native Method)
08-15 11:42:43.755: E/AndroidRuntime(1864): Caused by: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
08-15 11:42:43.755: E/AndroidRuntime(1864):     at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:275)
08-15 11:42:43.755: E/AndroidRuntime(1864):     at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2872)
08-15 11:42:43.755: E/AndroidRuntime(1864):     at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3129)
08-15 11:42:43.755: E/AndroidRuntime(1864):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:303)
08-15 11:42:43.755: E/AndroidRuntime(1864):     at android.app.Activity.setContentView(Activity.java:1930)
08-15 11:42:43.755: E/AndroidRuntime(1864):     at com.example.helloworld.MainActivity.onCreate(MainActivity.java:14)
08-15 11:42:43.755: E/AndroidRuntime(1864):     at android.app.Activity.performCreate(Activity.java:5242)
08-15 11:42:43.755: E/AndroidRuntime(1864):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
08-15 11:42:43.755: E/AndroidRuntime(1864):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)
08-15 11:42:43.755: E/AndroidRuntime(1864):     ... 11 more

I think you are targeting the wrong device. 我认为您定位的设备错误。 If memory serves me right, it sounds like you might be targeting Android Wear. 如果记忆体对我来说正确,听起来您可能要锁定Android Wear。

If you are developing a mobile application, change your target sdk to API 19 如果要开发移动应用程序,请将目标SDK更改为API 19

在清单.xml中,将target-sdk更改为19!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM