31

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

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

MainActivity.Java

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

activity_main.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"

 >

    <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" />
Xaver Kapeller
  • 49,491
  • 11
  • 98
  • 86
user3797788
  • 321
  • 1
  • 3
  • 4

9 Answers9

33

4.4W is Android Wear SDK. (dont target to android wear device)

try changing target sdk version to 19

As mentioned in another answer:

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 ADV everything runs as it should.

Dharman
  • 30,962
  • 25
  • 85
  • 135
SHASHIDHAR MANCHUKONDA
  • 3,302
  • 2
  • 19
  • 40
  • I'm on Platform 4.3 and API level 18. I dont have 4.2.2 with API level 19. Do I need to install this and test?. Is there any limitation on 4.2 with Level 19 – user3797788 Jul 05 '14 at 14:25
  • Thanks, its working. I have tried AVD with level 19 and platform 4.4.2. – user3797788 Jul 05 '14 at 15:00
  • 1
    The only thing I found confusing about the response above (and this may have been down to the non availability of Hardware at the time) was that this post referred to AVD devices rather than physical hardware, so I was a little thrown off by that. I looked at the following... https://github.com/9elements/9elements-One-for-Android-Wear This has a fully working watchface, more than enough to get the clues (Extract from mobile/build.gradle) android { ... defaultConfig { applicationId "bar.foo.mywatchapplication" minSdkVersion 9 targetSdkVersion 19 ... – Paul Maidment Jul 14 '14 at 19:00
17

I had the same issue. But sdk version was not the cause for this exception.

In the AndroidManifest.xml file you have the theme has ActionBar in it.

android:theme="@style/AppTheme" >

Change the above line to

android:theme="@android:style/Theme.DeviceDefault" >

That will fix the exception.

9

4.4W is Android Wear SDK.

This error is because the device you are targeting is Android Wear which has a different design pattern.

If you are developing a mobile application, change your AVD and target any API below 20 or choose API 20 (L preview).

Or if you are really targeting for Android Wear, change your app design.

Peter O.
  • 32,158
  • 14
  • 82
  • 96
vinksharma
  • 557
  • 4
  • 4
5

Am using Android Studio beta 0.8.6 with java 7. I had the same issue. And fixed it this way.

In the AndroidManifest.xml file you have the theme has ActionBar in it.

android:theme="@style/AppTheme" >

Change the above line to

android:theme="@android:style/Theme.DeviceDefault" >

That will fix the exception. As mentioned by Gangadhar in prev answer ,sdk version was not the cause for this exception.

And tested it with helloWorld app.

user989383
  • 391
  • 4
  • 3
2

I got this error because I tried to run the mobile part of a wear project on the Samsung Gear device. After switching from "mobile" to "wear" in the run configurations, everything worked (API level 20 and platform 4.4W is indeed the right choice in this case).

1

I got this problem when trying to create the project in Eclipse.
I had to add the following to the manifest file:

<uses-feature android:name="android.hardware.type.watch" />
TheTall
  • 298
  • 3
  • 7
1

go to values/styles.xml and set the styles as follow:

<resources>

    <!--
        Base application theme, dependent on API level. This theme is replaced
        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
    -->
    <style name="AppBaseTheme" parent="android:Theme.DeviceDefault">
        <!--
            Theme customizations available in newer API levels can go in
            res/values-vXX/styles.xml, while customizations related to
            backward-compatibility can go here.
        -->
    </style>

    <!-- Application theme. -->
    <style name="AppTheme" parent="AppBaseTheme">
        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
    </style>

</resources>

Also, in folders res/values-v11 and res/values-v14, and all folders in values-vxx change the styles.xml file as follows:

<resources>

    <!--
        Base application theme for API 14+. This theme completely replaces
        AppBaseTheme from BOTH res/values/styles.xml and
        res/values-v11/styles.xml on API 14+ devices.
    -->
    <style name="AppBaseTheme" parent="android:Theme.DeviceDefault">
        <!-- API 14 theme customizations can go here. -->
    </style>

</resources>

You have not to add action bar themes as they are not compatible with wear devices.

0

Change target sdk version to 19

Install API level 19 and platform 4.4.2

Use API level 19 & platform 4.4.2 while running application in AVD.

Sreekumar
  • 37
  • 1
  • 9
0

I have struggle a lot to fix the issue. Nothing work for me except the changes I made in AndroidManifest.xml.

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

Remove android:targetSdkVersion, it worked for me, you can also try.

sashikanta
  • 341
  • 5
  • 19