When I run my activity, I get an IllegalStateException: You need to use a Theme.AppCompat theme
at random times. I just need to rebuild the project and the activity start on the next run, but after some runs, I get the exception again.
I checked that my application and activities themes inherit from Theme.AppCompat
. All my activities extends FragmentActivity
I get the exception on API 22 (Android 5.1.1) and I am running Android Studio 2.0 Beta 5
Edit
I used Android Studio 1.5 and I did not get the error. It seems that on AS 2.0, super
in my Activities refers to AppCompatActivity
and not to the inherited class FragmentActivity
. I can't understand this behavior
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="eu.heyway.heywayandroid">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.NoActionBar"
android:name=".HeyWayApplication">
<activity
android:name=".login.FacebookLoginActivity"
android:theme="@style/AppTheme.TriangleBackground">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".configuration.ConfigurationActivity"
android:label="@string/title_activity_configuration"
android:theme="@style/AppTheme.TriangleBackground" />
<activity android:name=".home.HomeActivity"
android:theme="@style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
styles.xml
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:windowBackground">@color/colorPrimary</item>
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
</style>
<style name="AppTheme.TriangleBackground" parent="AppTheme">
<item name="android:windowBackground">@drawable/background_full</item>
</style>
All my activities extends this class :
public class BaseActivity extends FragmentActivity {
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
}
}
I was wondering if I should report this as a bug or if I am doing something wrong.