刚刚接触Android,创建了一个project直接运行报错,求指导!多谢!

Android 码拜 9年前 (2015-05-10) 900次浏览 0个评论
 

Console:
—————————————————————————————
[2014-07-18 13:01:18 – helloAndroid] Android Launch!
[2014-07-18 13:01:18 – helloAndroid] adb is running normally.
[2014-07-18 13:01:18 – helloAndroid] Performing com.example.helloandroid.MainActivity activity launch
[2014-07-18 13:01:18 – helloAndroid] Automatic Target Mode: using existing emulator “”emulator-5554″” running compatible AVD “”test””
[2014-07-18 13:01:18 – helloAndroid] Uploading helloAndroid.apk onto device “”emulator-5554″”
[2014-07-18 13:01:19 – helloAndroid] Installing helloAndroid.apk…
[2014-07-18 13:01:31 – helloAndroid] Success!
[2014-07-18 13:01:31 – helloAndroid] Starting activity com.example.helloandroid.MainActivity on device emulator-5554
[2014-07-18 13:01:32 – helloAndroid] ActivityManager: WARNING: linker: libdvm.so has text relocations. This is wasting memory and prevents security hardening. Please fix.
[2014-07-18 13:01:34 – helloAndroid] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.helloandroid/.MainActivity }

LogCat:
————————————————————————————–
07-18 05:00:20.234: E/AndroidRuntime(1888): FATAL EXCEPTION: main
07-18 05:00:20.234: E/AndroidRuntime(1888): Process: com.example.helloandroid, PID: 1888
07-18 05:00:20.234: E/AndroidRuntime(1888): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.helloandroid/com.example.helloandroid.MainActivity}: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
07-18 05:00:20.234: E/AndroidRuntime(1888):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197)
07-18 05:00:20.234: E/AndroidRuntime(1888):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258)
07-18 05:00:20.234: E/AndroidRuntime(1888):  at android.app.ActivityThread.access$800(ActivityThread.java:138)
07-18 05:00:20.234: E/AndroidRuntime(1888):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
07-18 05:00:20.234: E/AndroidRuntime(1888):  at android.os.Handler.dispatchMessage(Handler.java:102)
07-18 05:00:20.234: E/AndroidRuntime(1888):  at android.os.Looper.loop(Looper.java:136)
07-18 05:00:20.234: E/AndroidRuntime(1888):  at android.app.ActivityThread.main(ActivityThread.java:5026)
07-18 05:00:20.234: E/AndroidRuntime(1888):  at java.lang.reflect.Method.invokeNative(Native Method)
07-18 05:00:20.234: E/AndroidRuntime(1888):  at java.lang.reflect.Method.invoke(Method.java:515)
07-18 05:00:20.234: E/AndroidRuntime(1888):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
07-18 05:00:20.234: E/AndroidRuntime(1888):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
07-18 05:00:20.234: E/AndroidRuntime(1888):  at dalvik.system.NativeStart.main(Native Method)
07-18 05:00:20.234: E/AndroidRuntime(1888): Caused by: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
07-18 05:00:20.234: E/AndroidRuntime(1888):  at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:275)
07-18 05:00:20.234: E/AndroidRuntime(1888):  at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2872)
07-18 05:00:20.234: E/AndroidRuntime(1888):  at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3129)
07-18 05:00:20.234: E/AndroidRuntime(1888):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:303)
07-18 05:00:20.234: E/AndroidRuntime(1888):  at android.app.Activity.setContentView(Activity.java:1930)
07-18 05:00:20.234: E/AndroidRuntime(1888):  at android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217)
07-18 05:00:20.234: E/AndroidRuntime(1888):  at android.support.v7.app.ActionBarActivityDelegateICS.setContentView(ActionBarActivityDelegateICS.java:110)
07-18 05:00:20.234: E/AndroidRuntime(1888):  at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77)
07-18 05:00:20.234: E/AndroidRuntime(1888):  at com.example.helloandroid.MainActivity.onCreate(MainActivity.java:14)
07-18 05:00:20.234: E/AndroidRuntime(1888):  at android.app.Activity.performCreate(Activity.java:5242)
07-18 05:00:20.234: E/AndroidRuntime(1888):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
07-18 05:00:20.234: E/AndroidRuntime(1888):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)
07-18 05:00:20.234: E/AndroidRuntime(1888):  … 11 more

同问……我也遇到了一样的问题……
确定你源文件中的activity的类名和xml中的是否一致。
引用 2 楼 wm_hust 的回复:

确定你源文件中的activity的类名和xml中的是否一致。

你好,我查看了一下,你所讲的xml应该是Manifest.xml中的android:name吧,是跟activity类名一样的,都是android:name=”.MainActivity”

自己顶一下!继续求助!
at com.example.helloandroid.MainActivity.onCreate(MainActivity.java:14)

看看MainActivity类的第14行代码,有没有问题…

log里告诉你原因了
Caused by: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
具体在下面:
at com.example.helloandroid.MainActivity.onCreate(MainActivity.java:14)
很明显是在Activity创建时出错了,请检查oncreate()方法中是否有错,如果无法定位,请将代码粘贴出来供大家为你提供进一步帮助。
Caused by: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
引用 5 楼 u012301841 的回复:

at com.example.helloandroid.MainActivity.onCreate(MainActivity.java:14)

看看MainActivity类的第14行代码,有没有问题…

引用 6 楼 fireyou 的回复:

log里告诉你原因了
Caused by: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
具体在下面:
at com.example.helloandroid.MainActivity.onCreate(MainActivity.java:14)

引用 7 楼 lionfresh 的回复:

很明显是在Activity创建时出错了,请检查oncreate()方法中是否有错,如果无法定位,请将代码粘贴出来供大家为你提供进一步帮助。

引用 8 楼 u011631889 的回复:

Caused by: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.

感谢大家~下面是代码
12 protected void onCreate(Bundle savedInstanceState) {
13 super.onCreate(savedInstanceState);
14 setContentView(R.layout.activity_main);
15 TextView tv=new TextView(this);
16 tv.setText(“Hello World”);
17 setContentView(tv);
18 }

http://blog.csdn.net/jansin_love/article/details/8845419

或者你把application的style属性修改下

07-23 09:30:51.306: E/AndroidRuntime(1752): FATAL EXCEPTION: main
07-23 09:30:51.306: E/AndroidRuntime(1752): Process: com.android.criminallnetent, PID: 1752
07-23 09:30:51.306: E/AndroidRuntime(1752): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.criminallnetent/com.android.criminallnetent.CrimeListActivity}: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.

———————————————————————————————–
try changing target sdk version to 19
check here targetSdkVersion setting
Do not use API Level of 20 and Platform 4.4W, as Android Virtual Device. With Level 19 and Platform 4.2.2 set on AVD everything runs as it should.

 <uses-sdk
        android:minSdkVersion=”8″
        android:targetSdkVersion=”17″ />

20分
创建虚拟机的时候不要用android4.4 ,还有把xml文件中 目标sdk换成小于20的
引用 12 楼 android_freshman 的回复:

创建虚拟机的时候不要用android4.4 ,还有把xml文件中 目标sdk换成小于20的

恩,今天我google了一下, 发现也有人有类似的问题,卸载api 20更换成19的就没有问题了,多谢大家。

网上有更好的解决方法,大家应该努力搜嘛,就不用这么折腾了
更改 styles.xml 文件:
<style name=”AppTheme” parent=”android:Theme.DeviceDefault“>  
不好意思,api20是用于可穿戴设备开发的,还是得转到api19下面去或更高版本
我也碰到了同样的问题
你是不是设置全屏了?我之前也遇到类似的问题,是因为我把设置全屏的代码放在了 setContentView(R.layout.menu_main);后面。你只要把这句话放到设置全屏语句的后面就ok了。
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

//设置无标题  
        requestWindowFeature(Window.FEATURE_NO_TITLE);  
        //设置全屏  
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,   
                WindowManager.LayoutParams.FLAG_FULLSCREEN); 
setContentView(R.layout.menu_main);
        

}


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明刚刚接触Android,创建了一个project直接运行报错,求指导!多谢!
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!