我就是新建了helloworld项目,activity选的blankactivity,其他都是默认,也没有对代码做任何改动,run的时候报如下信息,求高手指导。
10-14 02:18:56.908: D/AndroidRuntime(2146): Shutting down VM
10-14 02:18:56.918: W/dalvikvm(2146): threadid=1: thread exiting with uncaught exception (group=0xb1dc4ce8)
10-14 02:18:56.928: E/AndroidRuntime(2146): FATAL EXCEPTION: main
10-14 02:18:56.928: E/AndroidRuntime(2146): Process: com.example.helloworld, PID: 2146
10-14 02:18:56.928: E/AndroidRuntime(2146): 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.
10-14 02:18:56.928: E/AndroidRuntime(2146): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197)
10-14 02:18:56.928: E/AndroidRuntime(2146): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258)
10-14 02:18:56.928: E/AndroidRuntime(2146): at android.app.ActivityThread.access$800(ActivityThread.java:138)
10-14 02:18:56.928: E/AndroidRuntime(2146): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
10-14 02:18:56.928: E/AndroidRuntime(2146): at android.os.Handler.dispatchMessage(Handler.java:102)
10-14 02:18:56.928: E/AndroidRuntime(2146): at android.os.Looper.loop(Looper.java:136)
10-14 02:18:56.928: E/AndroidRuntime(2146): at android.app.ActivityThread.main(ActivityThread.java:5026)
10-14 02:18:56.928: E/AndroidRuntime(2146): at java.lang.reflect.Method.invokeNative(Native Method)
10-14 02:18:56.928: E/AndroidRuntime(2146): at java.lang.reflect.Method.invoke(Method.java:515)
10-14 02:18:56.928: E/AndroidRuntime(2146): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
10-14 02:18:56.928: E/AndroidRuntime(2146): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
10-14 02:18:56.928: E/AndroidRuntime(2146): at dalvik.system.NativeStart.main(Native Method)
10-14 02:18:56.928: E/AndroidRuntime(2146): Caused by: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
10-14 02:18:56.928: E/AndroidRuntime(2146): at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:277)
10-14 02:18:56.928: E/AndroidRuntime(2146): at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2889)
10-14 02:18:56.928: E/AndroidRuntime(2146): at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3154)
10-14 02:18:56.928: E/AndroidRuntime(2146): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:305)
10-14 02:18:56.928: E/AndroidRuntime(2146): at android.app.Activity.setContentView(Activity.java:1930)
10-14 02:18:56.928: E/AndroidRuntime(2146): at android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217)
10-14 02:18:56.928: E/AndroidRuntime(2146): at android.support.v7.app.ActionBarActivityDelegateICS.setContentView(ActionBarActivityDelegateICS.java:110)
10-14 02:18:56.928: E/AndroidRuntime(2146): at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77)
10-14 02:18:56.928: E/AndroidRuntime(2146): at com.example.helloworld.MainActivity.onCreate(MainActivity.java:14)
10-14 02:18:56.928: E/AndroidRuntime(2146): at android.app.Activity.performCreate(Activity.java:5242)
10-14 02:18:56.928: E/AndroidRuntime(2146): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
10-14 02:18:56.928: E/AndroidRuntime(2146): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)
10-14 02:18:56.928: E/AndroidRuntime(2146): ... 11 more
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.
at com.example.helloworld.MainActivity.onCreate(MainActivity.java:14)
写的挺清楚嘛 MainActivity 14行 onCreate里有问题
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
这个是系统自动生成的函数,求问里面什么地方有问题呢?我是菜鸟,不好意思
@Jingle Guo: 额 这个没问题 你把Manifest.xml贴出来看看
@Jingle Guo: 或者右键项目 android tools->run lint:check... 看看error怎么写的
@Rossoneri.Du:
AndroidManifest.xml代码
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.helloworld" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="20" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name=".MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
error信息很奇怪
@Jingle Guo: targetSdkVersion改到20以下试试 20太高了 改16吧
@Rossoneri.Du:
显示以下的内容后就迟迟不出结果了,虚拟机都已经打开了但是结果没有。
[2014-10-14 15:40:20 - helloWorld] ------------------------------
[2014-10-14 15:40:20 - helloWorld] Android Launch!
[2014-10-14 15:40:20 - helloWorld] adb is running normally.
[2014-10-14 15:40:20 - helloWorld] Performing com.example.helloworld.MainActivity activity launch
[2014-10-14 15:40:20 - helloWorld] Automatic Target Mode: launching new emulator with compatible AVD 'xnj'
[2014-10-14 15:40:20 - helloWorld] Launching a new emulator with Virtual Device 'xnj'
[2014-10-14 15:41:12 - Emulator] emulator: warning: opening audio input failed
[2014-10-14 15:41:12 - Emulator]
[2014-10-14 15:41:14 - helloWorld] New emulator found: emulator-5554
[2014-10-14 15:41:14 - helloWorld] Waiting for HOME ('android.process.acore') to be launched...
android tools->run lint:check... 信息和之前帖的一样
@Jingle Guo: 额 能跑起来 没结果? 那不清楚了,我没用过AVD,都是真机上跑的。。