我正在使用android studio版本0.8.0和Android Studio入门教程 作者:Sashen Govender。我遇到了以下错误“很遗憾Hello Android已停止”我需要你的帮助,这是
我第一次使用这个软件。
我的xml文件是:
<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"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MyActivity">
<TextView
android:text="@string/hello_world"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
我的Android清单是:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.ker_david.helloandroid" >
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MyActivity"
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>
MyActivity.java是
Package com.example.ker_david.helloandroid;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
public class MyActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.my, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
这是我的logcat文件:
08-27 08:35:36.500 770-770/com.example.ker_david.helloandroid D/dalvikvm﹕ Not late-enabling CheckJNI (already on)
08-27 08:35:37.060 770-770/com.example.ker_david.helloandroid D/AndroidRuntime﹕ Shutting down VM
08-27 08:35:37.060 770-770/com.example.ker_david.helloandroid W/dalvikvm﹕ threadid=1: thread exiting with uncaught
exception (group=0xb3aaad70)
08-27 08:35:37.070 770-770/com.example.ker_david.helloandroid E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.ker_david.helloandroid, PID: 770
java.lang.RuntimeException: Unable to start activity ComponentInfo
{com.example.ker_david.helloandroid/com.example.ker_david.helloandroid.MyActivity}: android.util.AndroidRuntimeException:
You cannot combine swipe dismissal and the action bar.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258)
at android.app.ActivityThread.access$800(ActivityThread.java:138)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5026)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:275)
at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2872)
at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3129)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:303)
at android.app.Activity.setContentView(Activity.java:1930)
at com.example.ker_david.helloandroid.MyActivity.onCreate(MyActivity.java:14)
at android.app.Activity.performCreate(Activity.java:5242)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258)
at android.app.ActivityThread.access$800(ActivityThread.java:138)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5026)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
at dalvik.system.NativeStart.main(Native Method)
08-27 08:40:37.390 770-770/com.example.ker_david.helloandroid I/Process﹕ Sending signal. PID: 770 SIG: 9
请协助
答案 0 :(得分:0)
我认为您必须在清单中设置minSdk和targetSdkVersion:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />