I've recently upgraded my application to a material theme. However, I'm encountering crashes on a 4.2.2 Samsung tablet. The stacktrace (posted below) tells me that I am not using a descendant of Theme.AppCompat, even though I believe I am. The app seems to run fine on 4.4 and 5.0.
Here is the stacktrace from the Samsung tablet:
02-23 19:21:29.490: E/AndroidRuntime(20724): FATAL EXCEPTION: main
02-23 19:21:29.490: E/AndroidRuntime(20724): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.app.name/com.app.name.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
02-23 19:21:29.490: E/AndroidRuntime(20724): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2245)
02-23 19:21:29.490: E/AndroidRuntime(20724): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2295)
02-23 19:21:29.490: E/AndroidRuntime(20724): at android.app.ActivityThread.access$700(ActivityThread.java:150)
02-23 19:21:29.490: E/AndroidRuntime(20724): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280)
02-23 19:21:29.490: E/AndroidRuntime(20724): at android.os.Handler.dispatchMessage(Handler.java:99)
02-23 19:21:29.490: E/AndroidRuntime(20724): at android.os.Looper.loop(Looper.java:175)
02-23 19:21:29.490: E/AndroidRuntime(20724): at android.app.ActivityThread.main(ActivityThread.java:5279)
02-23 19:21:29.490: E/AndroidRuntime(20724): at java.lang.reflect.Method.invokeNative(Native Method)
02-23 19:21:29.490: E/AndroidRuntime(20724): at java.lang.reflect.Method.invoke(Method.java:511)
02-23 19:21:29.490: E/AndroidRuntime(20724): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
02-23 19:21:29.490: E/AndroidRuntime(20724): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
02-23 19:21:29.490: E/AndroidRuntime(20724): at dalvik.system.NativeStart.main(Native Method)
02-23 19:21:29.490: E/AndroidRuntime(20724): Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
02-23 19:21:29.490: E/AndroidRuntime(20724): at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:151)
02-23 19:21:29.490: E/AndroidRuntime(20724): at android.support.v7.app.ActionBarActivityDelegateBase.onCreate(ActionBarActivityDelegateBase.java:138)
02-23 19:21:29.490: E/AndroidRuntime(20724): at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:123)
02-23 19:21:29.490: E/AndroidRuntime(20724): at com.appconstructor.core2.MainActivity.onCreate(MainActivity.java:56)
02-23 19:21:29.490: E/AndroidRuntime(20724): at com.app.name.MainActivity.onCreate(MainActivity.java:12)
02-23 19:21:29.490: E/AndroidRuntime(20724): at android.app.Activity.performCreate(Activity.java:5283)
02-23 19:21:29.490: E/AndroidRuntime(20724): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
02-23 19:21:29.490: E/AndroidRuntime(20724): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2209)
02-23 19:21:29.490: E/AndroidRuntime(20724): ... 11 more
My app uses a library for the activities. The Manifest looks like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.app.name"
android:versionCode="501"
android:versionName="5.0.1" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="21" />
[... Permissions]
<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>
[... Other activities]
[... etc]
</application>
</manifest>
/res/values/styles.xml
is contained in the library and looks like this:
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
<!-- enable window content transitions -->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
As you can see, AppTheme does extend Theme.AppCompat!
There's some other values
folders, but none of them seem applicable. I have values-nl for the Dutch translation, values-v19
and values-v21
and then there's values-w820dp
which doesn't contain a styles.xml. There's no styles in the main app.
So, I'm obviously missing something. What could it be?\
Update 1: since the tablet is actually really slow, I can see the activity actually loading up as holo. So the problem is that the wrong theme is loaded.