Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

The fun Facts app cannot be launched for the first time

hey, I just finished the part where i have to run the emulator, everything's ok except when i want to launch the application on the emulator, then i have these messages shown in the catlog:

09-09 15:03:38.720: E/AndroidRuntime(858): FATAL EXCEPTION: main

09-09 15:03:38.720: E/AndroidRuntime(858): Process: com.example.funfacts, PID: 858

09-09 15:03:38.720: E/AndroidRuntime(858): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.funfacts/com.example.funfacts.FunFactsActivity}: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.

09-09 15:03:38.720: E/AndroidRuntime(858): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197)

09-09 15:03:38.720: E/AndroidRuntime(858): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258)

09-09 15:03:38.720: E/AndroidRuntime(858): at android.app.ActivityThread.access$800(ActivityThread.java:138)

09-09 15:03:38.720: E/AndroidRuntime(858): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)

09-09 15:03:38.720: E/AndroidRuntime(858): at android.os.Handler.dispatchMessage(Handler.java:102)

09-09 15:03:38.720: E/AndroidRuntime(858): at android.os.Looper.loop(Looper.java:136)

09-09 15:03:38.720: E/AndroidRuntime(858): at android.app.ActivityThread.main(ActivityThread.java:5026)

09-09 15:03:38.720: E/AndroidRuntime(858): at java.lang.reflect.Method.invokeNative(Native Method)

09-09 15:03:38.720: E/AndroidRuntime(858): at java.lang.reflect.Method.invoke(Method.java:515)

09-09 15:03:38.720: E/AndroidRuntime(858): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)

09-09 15:03:38.720: E/AndroidRuntime(858): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)

09-09 15:03:38.720: E/AndroidRuntime(858): at dalvik.system.NativeStart.main(Native Method)

09-09 15:03:38.720: E/AndroidRuntime(858): Caused by: android.util.AndroidRuntimeException: You cannot combine swipe dismissal and the action bar.

09-09 15:03:38.720: E/AndroidRuntime(858): at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:275)

09-09 15:03:38.720: E/AndroidRuntime(858): at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2872)

09-09 15:03:38.720: E/AndroidRuntime(858): at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3129)

09-09 15:03:38.720: E/AndroidRuntime(858): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:303)

09-09 15:03:38.720: E/AndroidRuntime(858): at android.app.Activity.setContentView(Activity.java:1930)

09-09 15:03:38.720: E/AndroidRuntime(858): at com.example.funfacts.FunFactsActivity.onCreate(FunFactsActivity.java:14)

09-09 15:03:38.720: E/AndroidRuntime(858): at android.app.Activity.performCreate(Activity.java:5242)

09-09 15:03:38.720: E/AndroidRuntime(858): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)

09-09 15:03:38.720: E/AndroidRuntime(858): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)

09-09 15:03:38.720: E/AndroidRuntime(858): ... 11 more

3 Answers

Justin Horner
STAFF
Justin Horner
Treehouse Guest Teacher

Hello Cocuelle,

Check your platform to make sure you're not trying to run against Android Wear, which is 4.4W. Also, make sure you're running lower than API 20, as 20 is the L Preview.

I would try running with API 19, Platform 4.4.2.

I hope this helps.

Hello,

I've heard a few users struggle with this actually.

I previously did a bit of research on this and believe that the SDK version is to fault. What you've probably done is used the SDK for Smartwatches (The Android Wear SDK).

In your build.gradle file (I think it's found in the android folder), use the following code:

android {
    compileSdkVersion lpreview ? "android-L" : 19
    buildToolsVersion "19.1.0"

    productFlavors { lpreview ? lpreview{} : classic{} }

    defaultConfig lpreview ? {} : {
        // Non-L-preview configuration
        minSdkVersion 14
        targetSdkVersion 19
    }

The issue is that you used Android 4.4W (It's easy to do: http://gyazo.com/1f582d03bd1afd18c377100beb209d00) which is the Android Wear SDK however, that's also API 20 right now!

Yeah. The fun of Android! Anyhow, you shouldn't have this issue when Android L is officially released but, this fix will work for now. It should allow you to choose between 4.4.2 and Android L.

Thanks you so much for the fast answer, and by checking now i realise i did a stupid mistake grabbing the 4.4.W instead of 4.4.2 while downloading !

Justin Horner
Justin Horner
Treehouse Guest Teacher

Glad the issue is solved! Happy coding :)