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 trialBenjamin Earle
6,204 PointsYou need to use a Theme.AppCompat theme (or descendant) with this activity.
Hi! Im getting a crash on my Ribbit app, and on the logcat I get:
03-05 22:08:42.551 1670-1670/com.benjamin.snapshot E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.benjamin.snapshot/com.benjamin.snapshot.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:147)
at android.support.v7.app.ActionBarActivityDelegateBase.onCreate(ActionBarActivityDelegateBase.java:139)
at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:123)
at com.benjamin.snapshot.MainActivity.onCreate(MainActivity.java:168)
at android.app.Activity.performCreate(Activity.java:5133)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
This only happened to me when I changed the app theme. I've tried the solutions on the other questions and they havent helped me.
If it is of any use, here's my styles.xml:
<?xml version="1.0" encoding="utf-8"?>
<!-- File created by the Android Action Bar Style Generator
Copyright (C) 2011 The Android Open Source Project
Copyright (C) 2012 readyState Software Ltd
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android">
<style name="Theme.Ribbit" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarItemBackground">@drawable/selectable_background_ribbit</item>
<item name="android:popupMenuStyle">@style/PopupMenu.Ribbit</item>
<item name="android:dropDownListViewStyle">@style/DropDownListView.Ribbit</item>
<item name="android:actionBarTabStyle">@style/ActionBarTabStyle.Ribbit</item>
<item name="android:actionDropDownStyle">@style/DropDownNav.Ribbit</item>
<item name="android:actionBarStyle">@style/ActionBar.Solid.Ribbit</item>
<item name="android:actionModeBackground">@mipmap/cab_background_top_ribbit</item>
<item name="android:actionModeSplitBackground">@mipmap/cab_background_bottom_ribbit</item>
<item name="android:actionModeCloseButtonStyle">@style/ActionButton.CloseMode.Ribbit</item>
<item name="android:editTextBackground">@drawable/apptheme_edit_text_holo_light</item>
</style>
<style name="ActionBar.Solid.Ribbit" parent="@android:style/Widget.Holo.Light.ActionBar.Solid">
<item name="android:background">@mipmap/ab_solid_ribbit</item>
<item name="android:backgroundStacked">@mipmap/ab_stacked_solid_ribbit</item>
<item name="android:backgroundSplit">@mipmap/ab_bottom_solid_ribbit</item>
<item name="android:progressBarStyle">@style/ProgressBar.Ribbit</item>
</style>
<style name="ActionBar.Transparent.Ribbit" parent="@android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">@mipmap/ab_transparent_ribbit</item>
<item name="android:progressBarStyle">@style/ProgressBar.Ribbit</item>
</style>
<style name="PopupMenu.Ribbit" parent="@android:style/Widget.Holo.Light.ListPopupWindow">
<item name="android:popupBackground">@mipmap/menu_dropdown_panel_ribbit</item>
</style>
<style name="DropDownListView.Ribbit" parent="@android:style/Widget.Holo.Light.ListView.DropDown">
<item name="android:listSelector">@drawable/selectable_background_ribbit</item>
</style>
<style name="ActionBarTabStyle.Ribbit" parent="@android:style/Widget.Holo.Light.ActionBar.TabView">
<item name="android:background">@drawable/tab_indicator_ab_ribbit</item>
</style>
<style name="DropDownNav.Ribbit" parent="@android:style/Widget.Holo.Light.Spinner">
<item name="android:background">@drawable/spinner_background_ab_ribbit</item>
<item name="android:popupBackground">@mipmap/menu_dropdown_panel_ribbit</item>
<item name="android:dropDownSelector">@drawable/selectable_background_ribbit</item>
</style>
<style name="ProgressBar.Ribbit" parent="@android:style/Widget.Holo.Light.ProgressBar.Horizontal">
<item name="android:progressDrawable">@drawable/progress_horizontal_ribbit</item>
</style>
<style name="ActionButton.CloseMode.Ribbit" parent="@android:style/Widget.Holo.Light.ActionButton.CloseMode">
<item name="android:background">@drawable/btn_cab_done_ribbit</item>
</style>
<!-- this style is only referenced in a Light.DarkActionBar based theme -->
<style name="Theme.Ribbit.Widget" parent="@android:style/Theme.Holo">
<item name="android:popupMenuStyle">@style/PopupMenu.Ribbit</item>
<item name="android:dropDownListViewStyle">@style/DropDownListView.Ribbit</item>
</style>
<style name="AuthBackground">
<item name="android:background">@mipmap/background_fill</item>
</style>
<style name="AuthBackgroundImage">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">match_parent</item>
<item name="android:layout_alignParentTop">true</item>
<item name="android:layout_alignParentLeft">true</item>
<item name="android:layout_alignParentStart">true</item>
<item name="android:src">@mipmap/background</item>
<item name="android:scaleType">fitStart</item>
<item name="android:contentDescription">@string/content_desc_background</item>
</style>
<style name="AuthTitle" parent="android:Widget.Holo.Light.TextView">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_centerHorizontal">true</item>
<item name="android:layout_alignParentTop">true</item>
<item name="android:layout_marginTop">32dp</item>
<item name="android:textSize">60sp</item>
<item name="android:textColor">@android:color/white</item>
<item name="android:textStyle">bold</item>
</style>
<style name="AuthSubtitle" parent="AuthTitle">
<item name="android:layout_centerHorizontal">true</item>
<item name="android:layout_below">@+id/title</item>
<item name="android:textSize">13sp</item>
<item name="android:layout_alignParentTop">false</item>
<item name="android:layout_marginTop">0dp</item>
</style>
<style name="AuthFieldContainer">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:orientation">vertical</item>
<item name="android:layout_below">@id/subtitle</item>
<item name="android:layout_marginTop">@dimen/login_vertical_margin</item>
<item name="android:layout_marginLeft">@dimen/activity_horizontal_margin</item>
<item name="android:layout_marginRight">@dimen/activity_horizontal_margin</item>
<item name="android:background">@android:color/white</item>
<item name="android:paddingLeft">@dimen/login_horizontal_padding</item>
<item name="android:paddingRight">@dimen/login_horizontal_padding</item>
<item name="android:paddingTop">@dimen/login_vertical_padding</item>
<item name="android:paddingBottom">@dimen/login_vertical_padding</item>
</style>
<style name="AuthEditText">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColorHint">@color/light_gray</item>
<item name="android:textSize">17sp</item>
<item name="android:ems">10</item>
</style>
<style name="AuthButton">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:background">@drawable/button_custom</item>
<item name="android:layout_marginLeft">@dimen/activity_horizontal_margin</item>
<item name="android:layout_marginRight">@dimen/activity_horizontal_margin</item>
<item name="android:textSize">13sp</item>
<item name="android:textColor">@color/text_color</item>
</style>
</resources>
and my manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.benjamin.snapshot" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-feature
android:name="android.hardware.camera"
android:required="true" />
<application
android:name=".SnapShotApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Ribbit" >
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".LoginActivity"
android:label="@string/title_activity_login"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".SignUpActivity"
android:label="@string/title_activity_sign_up"
android:parentActivityName=".LoginActivity"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".EditFriendsActivity"
android:label="@string/title_activity_edit_friends"
android:parentActivityName=".MainActivity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Holo.Light.DarkActionBar" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.benjamin.snapshot.MainActivity" />
</activity>
<activity
android:name=".RecipientsActivity"
android:label="@string/title_activity_recipients"
android:parentActivityName=".MainActivity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Holo.Light.DarkActionBar" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.benjamin.snapshot.MainActivity" />
</activity>
<activity
android:name=".ViewImageActivity"
android:label="@string/app_name"
android:parentActivityName=".MainActivity"
android:screenOrientation="portrait">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.benjamin.snapshot.MainActivity" />
</activity>
</application>
</manifest>
Please help me solve this! I'm really liking how the app looks!
4 Answers
Ken Alger
Treehouse TeacherBenjamin;
In looking through your project I came across of a few issues, some of which I had in my own project as well when I was going through this course.
1) There are some support library issues which I think are causing the majority of the problem(s) with your project. They can be incredibly temperamental and frustrating to deal with and diagnose, but with a few adjustments I was able to get your app up and running.
2) I am not entirely certain why there are some graphical display issues with your project. There seems to be some extraneous graphic "additions" and distortions. This might be caused by the inclusion of a large number of your graphical files in the mipmap directories and not in the drawable directories. There are several indications that the mipmap directories are explicitly for the launcher icons. You can see this blog post as an example. If you look at the documentation for the R.mipmap class it references on the application icon. Remaining images should be in the drawable directories under the respective resolutions. I can't say for sure if that will fix all of the graphical issues, but I would certainly address the issue.
3) If you add my GitHub user name (kenwalger) to your project, I can upload my work and you can see what I was able to do.
Post back if you have any further questions.
Ken
Benjamin Earle
6,204 PointsOh, I see. Thats a lot of stuff I didn't know, but I guess thats how you learn! I've already added you to my project, thanks a lot for all your help!
Ken Alger
Treehouse TeacherBenjamin;
I just submitted a pull request on GitHub for your project. Take a look at the code differences and post back if you are still having issues.
Ken
Ken Alger
Treehouse TeacherBenjamin;
The error message you are getting appears to be in reference to the way you are implementing and/or extending ActionBarActivity
and how it is referenced in the styles.xml
file. One of the difficulties in diagnosing these types of errors, at least for me, is that there can be problematic points in several places, MainActivity
, styles.xml
, or the manifest. They all need to be correct to extend the ActionBarActivity
. The other difficulty is not knowing the exact stage of the project you currently are on as my code currently has the entire project, plus some additions.
So, how can we work through this?
1) I would say to download the project files from the specific stage video on which you are working. Then go through and compare your code with the course code. 2) If you are still stuck, create a GitHub repository for your code, or similar, and put the link here and we can download your code and see where the issue is.
Sorry to be such a pain with this, but I didn't see any "jump out at me" errors.
Happy to help, just post back and let us know.
Ken
Benjamin Earle
6,204 Pointshmmm, I will do all that I can, but I havent changed main activity since before I applied the style, and it was working perfectly at the time. After I check on the code I'll be back to say if I fixed it or not. Thanks!
Benjamin Earle
6,204 PointsKen, sorry for the trouble, but when trying to pull I get:
Error pulling origin: error: Your local changes to the following files would be overwritten by merge:
Isnt that what I want? Then how do I do it?
Ken Alger
Treehouse TeacherBenjamin;
If you accepted the pull request and merged it into Master you should be able to pull the repo down into your local environment. If you are still having issues you may want to clone the project into a new directory on your local machine (VCS -> Checkout from Version Control -> GitHub), which would also allow you to see the changes I made versus what you had and still be able to run both sets of code. That could be done with Git as well with Revert, but this way you could look at both codes simultaneously.
Post back with further questions.
Ken
Benjamin Earle
6,204 PointsI have tried fixing it in many different ways, but it hasnt worked, the closest thing to work was the solution here, but the layout just ended up looking screwed up (Screenshot). If you can find a solution by looking at the code, that would be wonderful! Thanks a lot in advance!
Benjamin Earle
6,204 PointsThe code you sent didn't work... The textures on main activity haven't changed and the ones on the log in screen broke, im sorry to say...
The good part is that it doesen't crash anymore, but all the graphics look blurry and off place, making it look horrible, do you know how to fix that?
Timothy Boland
18,237 PointsHi Benjamin,
What is the latest with this issue....I believe I am having the same problem
Steve Hunter
57,712 PointsSteve Hunter
57,712 PointsKen Alger - any thoughts?