0

I am new to this and i saw some tutorial and set up my emulator and all but when i run the hello world program the emulator says unfortunately the app has stopped

this is what my console looks like

[2014-08-01 23:43:21 - SagarAppProject] Android Launch!
[2014-08-01 23:43:21 - SagarAppProject] adb is running normally.
[2014-08-01 23:43:21 - SagarAppProject] Performing com.sagarappproject.MainActivity activity launch
[2014-08-01 23:43:21 - SagarAppProject] Automatic Target Mode: using existing emulator 'emulator-5554' running compatible AVD 'DroidX'
[2014-08-01 23:43:21 - SagarAppProject] Uploading SagarAppProject.apk onto device 'emulator-5554'
[2014-08-01 23:43:21 - SagarAppProject] Installing SagarAppProject.apk...
[2014-08-01 23:43:29 - SagarAppProject] Success!
[2014-08-01 23:43:29 - SagarAppProject] Starting activity com.sagarappproject.MainActivity on device emulator-5554
[2014-08-01 23:43:32 - SagarAppProject] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.sagarappproject/.MainActivity }

After this i get a lot of log file errors

08-01 16:30:22.400: D/AndroidRuntime(816): Shutting down VM
08-01 16:30:22.410: W/dalvikvm(816): threadid=1: thread exiting with uncaught exception (group=0xb2ae0d70)
08-01 16:30:22.420: E/AndroidRuntime(816): FATAL EXCEPTION: main
08-01 16:30:22.420: E/AndroidRuntime(816): Process: com.sagarappproject, PID: 816
08-01 16:30:22.420: E/AndroidRuntime(816): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sagarappproject/com.sagarappproject.MainActivity}: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
08-01 16:30:22.420: E/AndroidRuntime(816):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197)
08-01 16:30:22.420: E/AndroidRuntime(816):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258)
08-01 16:30:22.420: E/AndroidRuntime(816):  at android.app.ActivityThread.access$800(ActivityThread.java:138)
08-01 16:30:22.420: E/AndroidRuntime(816):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
08-01 16:30:22.420: E/AndroidRuntime(816):  at android.os.Handler.dispatchMessage(Handler.java:102)
08-01 16:30:22.420: E/AndroidRuntime(816):  at android.os.Looper.loop(Looper.java:136)
08-01 16:30:22.420: E/AndroidRuntime(816):  at android.app.ActivityThread.main(ActivityThread.java:5026)
08-01 16:30:22.420: E/AndroidRuntime(816):  at java.lang.reflect.Method.invokeNative(Native Method)
08-01 16:30:22.420: E/AndroidRuntime(816):  at java.lang.reflect.Method.invoke(Method.java:515)
08-01 16:30:22.420: E/AndroidRuntime(816):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
08-01 16:30:22.420: E/AndroidRuntime(816):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
08-01 16:30:22.420: E/AndroidRuntime(816):  at dalvik.system.NativeStart.main(Native Method)
08-01 16:30:22.420: E/AndroidRuntime(816): Caused by: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.
08-01 16:30:22.420: E/AndroidRuntime(816):  at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:275)
08-01 16:30:22.420: E/AndroidRuntime(816):  at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2872)
08-01 16:30:22.420: E/AndroidRuntime(816):  at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3129)
08-01 16:30:22.420: E/AndroidRuntime(816):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:303)
08-01 16:30:22.420: E/AndroidRuntime(816):  at android.app.Activity.setContentView(Activity.java:1930)
08-01 16:30:22.420: E/AndroidRuntime(816):  at   android.support.v7.app.ActionBarActivity.superSetContentView(ActionBarActivity.java:217)
08-01 16:30:22.420: E/AndroidRuntime(816):  at android.support.v7.app.ActionBarActivityDelegateICS.setContentView(ActionBarActivityDelegateICS.java:110)
08-01 16:30:22.420: E/AndroidRuntime(816):  at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:77)
08-01 16:30:22.420: E/AndroidRuntime(816):  at com.sagarappproject.MainActivity.onCreate(MainActivity.java:13)
08-01 16:30:22.420: E/AndroidRuntime(816):  at android.app.Activity.performCreate(Activity.java:5242)
08-01 16:30:22.420: E/AndroidRuntime(816):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
08-01 16:30:22.420: E/AndroidRuntime(816):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)
08-01 16:30:22.420: E/AndroidRuntime(816):  ... 11 more

And this is my AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sagarappproject"
android:versionCode="1"
android:versionName="1.0" >

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

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

And this is my activity.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"

android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="top"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.sagarappproject.MainActivity" >

<TextView
    android:id="@+id/TextView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="32dp"
    android:layout_marginTop="32dp"
    android:text="@string/hello_world" />
</RelativeLayout>
Sagar
  • 405
  • 1
  • 4
  • 16

3 Answers3

0

It seems others have had the same problem. Change android:targetSdkVersion to 19, as shown here

Community
  • 1
  • 1
mattbdean
  • 2,532
  • 5
  • 26
  • 58
0

See the answer here.

It states that

You cannot combine swipe dismissal and the action bar

as an sdk problem.

The answer tells you to change the target sdk version to 19

It also points out that

Do not mess up with API Level and Platform, as Android Virtual Device. With Level 19+ and Platform 4.2.2+ set on ADV everything runs as it should.

Community
  • 1
  • 1
Lal
  • 14,726
  • 4
  • 45
  • 70
0

The problem is that your emulator uses 4.4W API wich is android Wear. This means you cannot use the ActionBar on that emulator, becuase it uses the Wear framework. Try changing the emulator API level to 19 or 21. It should work then.

Gumbo
  • 1,716
  • 1
  • 15
  • 22