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

Error. You need to use a Theme.AppCompat theme (or descendant) with this activity.

While following the Android Crystal Ball application creation. I am stuck at stage three video one. How? It all starts when i try to change the activity and the manifest file themes to the full screen mode.

When I run the project i get this in my logcat

    java.lang.RuntimeException: Unable to start activity   ComponentInfo{apps.elitehive.com.crystalball/apps.elitehive.com.crystalball.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)

Below is my logcat

alt text

2 Answers

The error relates to java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity

The video in treehouse uses the Theme called ** Theme.Black.NoTitleBar.Fullscreen ** . Are you using this?

If yes, then the new android update no longer supports this. However there is a work around as proposed by treehouse


1) Change your project back to using "AppTheme" like it was before in AndroidManifest.xml and the preview.

2) Add the following two lines to the file res/values/styles.xml (inside the <style name="AppTheme"> tag):

<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>

3) Set the background color to black in the file res/layout/activity_main.xml. The root element, RelativeLayout, is the one that makes up the whole screen. Add this line after the layout_height line but before the closing angle bracket >:

android:background="@android:color/black"

4) Change MainActivity to extend Activity, not ActionBarActivity


Hope this helps. Ask again if you have doubts.

Thanks a lot Gunjeet Hattar

hmm, not sure but you may have not installed the appcompat. It should come with the crystal ball app in the project files. After downloading it you import it by going to file/import. Then add it by going to project/properties/android. Click on it, click add, click okay.

Thanks for the suggestion Louis Sankey but Gunjeet Hattar answer worked best.