我是新来的Android编程,并开始样品Hello World程序,但坚持了以下错误:
07-05 13:52:20.830:W / dalvikvm(898):主题ID = 1:螺纹退出与未捕获的异常(组= 0xb2ac4d70)
07-05 13:52:20.850:E / AndroidRuntime(898):致命异常:主要
07-05 13:52:20.850:E / AndroidRuntime(898):工艺:com.example.helloandroid,PID:898
07-05 13:52:20.850:E / AndroidRuntime(898):java.lang.RuntimeException的:无法启动的活动ComponentInfo {com.example.helloandroid / com.example.helloandroid.MainActivity}:android.util.AndroidRuntimeException:你不能将刷卡解雇和操作栏。
07-05 13:52:20.850:E / AndroidRuntime(898):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197)
07-05 13:52:20.850:E / AndroidRuntime(898):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258)
07-05 13:52:20.850:E / AndroidRuntime(898):在android.app.ActivityThread.access $ 800(ActivityThread.java:138)
07-05 13:52:20.850:E / AndroidRuntime(898):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1209)
07-05 13:52:20.850:E / AndroidRuntime(898):在android.os.Handler.dispatchMessage(Handler.java:102)
07-05 13:52:20.850:E / AndroidRuntime(898):在android.os.Looper.loop(Looper.java:136)
07-05 13:52:20.850:E / AndroidRuntime(898):在android.app.ActivityThread.main(ActivityThread.java:5026)
07-05 13:52:20.850:E / AndroidRuntime(898):在java.lang.reflect.Method.invokeNative(本机方法)
07-05 13:52:20.850:E / AndroidRuntime(898):在java.lang.reflect.Method.invoke(Method.java:515)
07-05 13:52:20.850:E / AndroidRuntime(898):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:777)
07-05 13:52:20.850:E / AndroidRuntime(898):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
07-05 13:52:20.850:E / AndroidRuntime(898):在dalvik.system.NativeStart.main(本机方法)
07-05 13:52:20.850:E / AndroidRuntime(898):android.util.AndroidRuntimeException:产生的原因不能将刷卡解雇和操作栏。
07-05 13:52:20.850:E / AndroidRuntime(898):在com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:275)
07-05 13:52:20.850:E / AndroidRuntime(898):在com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2872)
07-05 13:52:20.850:E / AndroidRuntime(898):在com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3129)
07-05 13:52:20.850:E / AndroidRuntime(898):在com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:303)
07-05 13:52:20.850:E / AndroidRuntime(898):在android.app.Activity.setContentView(Activity.java:1930)
07-05 13:52:20.850:E / AndroidRuntime(898):在com.example.helloandroid.MainActivity.onCreate(MainActivity.java:13)
07-05 13:52:20.850:E / AndroidRuntime(898):在android.app.Activity.performCreate(Activity.java:5242)
07-05 13:52:20.850:E / AndroidRuntime(898):在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
07-05 13:52:20.850:E / AndroidRuntime(898):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)
<舱单的xmlns:机器人=http://schemas.android.com/apk/res/android
包=com.example.helloandroid
安卓版code =1
机器人:VERSIONNAME =1.0>
<用途-SDK
安卓的minSdkVersion =8
机器人:targetSdkVersion =18/>
<应用
机器人:allowBackup =真
机器人:图标=@可绘制/ ic_launcher
机器人:标签=@字符串/ APP_NAME
机器人:主题=@风格/ AppTheme>
<活动
机器人:名称=com.example.helloandroid.MainActivity
机器人:标签=@字符串/ APP_NAME>
<意向滤光器>
<作用机器人:名称=android.intent.action.MAIN/>
<类机器人:名称=android.intent.category.LAUNCHER/>
&所述; /意图滤光器>
< /活性GT;
< /用途>
< /舱单>
包com.example.helloandroid;
进口android.app.Activity;
进口android.os.Bundle;
进口android.widget.TextView;
公共类MainActivity延伸活动{
/ **第一次创建活动时调用。 * /
@覆盖
公共无效的onCreate(包savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.activity_main);
}
}
< RelativeLayout的的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:工具=http://schemas.android.com/tools
机器人:layout_width =match_parent
机器人:layout_height =match_parent
>
<的TextView
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:文本=@字符串/你好/>
< / RelativeLayout的>
请帮我找出我要去哪里错了,我目前在Android 4.3,API 18,
我已经试过的Android 4.0.3 API 15,安卓4.4W API 20;我也曾尝试编辑SDK如下,但没有运气。
<使用-SDK
安卓的minSdkVersion =15
机器人:targetSdkVersion =19/>
解决方案
4.4W的Android Wear SDK。 (不要目标到Android设备的磨损)
请尝试更改目标SDK版本为19
点击这里 targetSdkVersion设置
不要使用20和平台4.4W API级别(也就是Android Wear SDK)作为Android虚拟设备。
使用API级别19和平台4.4.2一切工作正常。
I'm new to android programming and started a sample hello world program, but stuck with below error:
07-05 13:52:20.830: W/dalvikvm(898): threadid=1: thread exiting with uncaught exception (group=0xb2ac4d70)
07-05 13:52:20.850: E/AndroidRuntime(898): FATAL EXCEPTION: main
07-05 13:52:20.850: E/AndroidRuntime(898): Process: com.example.helloandroid, PID: 898
07-05 13:52:20.850: E/AndroidRuntime(898): 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-05 13:52:20.850: E/AndroidRuntime(898): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197)
07-05 13:52:20.850: E/AndroidRuntime(898): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258)
07-05 13:52:20.850: E/AndroidRuntime(898): at android.app.ActivityThread.access$800(ActivityThread.java:138)
07-05 13:52:20.850: E/AndroidRuntime(898): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
07-05 13:52:20.850: E/AndroidRuntime(898): at android.os.Handler.dispatchMessage(Handler.java:102)
07-05 13:52:20.850: E/AndroidRuntime(898): at android.os.Looper.loop(Looper.java:136)
07-05 13:52:20.850: E/AndroidRuntime(898): at android.app.ActivityThread.main(ActivityThread.java:5026)
07-05 13:52:20.850: E/AndroidRuntime(898): at java.lang.reflect.Method.invokeNative(Native Method)
07-05 13:52:20.850: E/AndroidRuntime(898): at java.lang.reflect.Method.invoke(Method.java:515)
07-05 13:52:20.850: E/AndroidRuntime(898): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
07-05 13:52:20.850: E/AndroidRuntime(898): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
07-05 13:52:20.850: E/AndroidRuntime(898): at dalvik.system.NativeStart.main(Native Method)
07-05 13:52:20.850: E/AndroidRuntime(898): Caused by: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
07-05 13:52:20.850: E/AndroidRuntime(898): at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:275)
07-05 13:52:20.850: E/AndroidRuntime(898): at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2872)
07-05 13:52:20.850: E/AndroidRuntime(898): at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3129)
07-05 13:52:20.850: E/AndroidRuntime(898): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:303)
07-05 13:52:20.850: E/AndroidRuntime(898): at android.app.Activity.setContentView(Activity.java:1930)
07-05 13:52:20.850: E/AndroidRuntime(898): at com.example.helloandroid.MainActivity.onCreate(MainActivity.java:13)
07-05 13:52:20.850: E/AndroidRuntime(898): at android.app.Activity.performCreate(Activity.java:5242)
07-05 13:52:20.850: E/AndroidRuntime(898): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
07-05 13:52:20.850: E/AndroidRuntime(898): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.helloandroid"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.helloandroid.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>
package com.example.helloandroid;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class MainActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello" />
</RelativeLayout>
Please help me to find out where I'm going wrong, I am currently on Android 4.3, API 18,
I've tried Android 4.0.3 API 15, Android 4.4W API 20; I have also tried editing sdk as below, but no luck.
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="19" />
解决方案
4.4W is Android Wear SDK. (dont target to android wear device)
try changing target sdk version to 19
check here targetSdkVersion setting
Do not use API Level of 20 and Platform 4.4W (which is Android Wear SDK) as Android Virtual Device.
Use API level 19 and platform 4.4.2 everything works fine.