简体   繁体   中英

Unfortunately HelloAndroid app has stopped

I am using android studio version 0.8.0 with the Getting Started with Android Studio tutorial by Sashen Govender. I encountered the following error "unfortunately Hello Android has stopped" I need your help, This is

my first time using this software.

My xml file is :

<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>

My Android Manifest is:

<?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 is

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);
    }
}

and this is my logcat file :

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

Please assist

I think you have to set the minSdk and targetSdkVersion in your manifest:

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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