Reputation: 1791
I have this exception for one user in production, it does not happen on my local builds on all the phones I tried and I cannot see what is wrong with my configuration.
Stack trace looks like:
Message: IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
android.support.v7.app.AppCompatDelegateImplV7.m in SourceFile::2309
android.support.v7.app.AppCompatDelegateImplV7.a in SourceFile::252
android.support.v7.app.AppCompatActivity.setContentView in SourceFile::109
my.package.HomeFragmentActivity.onCreate in SourceFile::80
My theme is defined as:
<style name="AppTheme" parent="@style/Theme.AppCompat.Light">
And my manifest is:
<application
android:name="my.package.Application"
android:allowBackup="false"
android:hardwareAccelerated="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:logo="@drawable/my_logo"
android:theme="@style/AppTheme">
...
<activity android:name="my.package.HomeFragmentActivity"
android:exported="false"
android:launchMode="singleTask"
android:screenOrientation="portrait"/>
Looking at the source for AppCompatDelegateImplV7, this exception is thrown if windowActionBar
is not present in the theme, which it sure looks like it is when I browse the hierarchy of the Theme.AppCompat.Light theme.
This is slightly older branch where the activity actually extends the deprecated ActionBarActivity
not AppCompatActivity
, but it seems to just use AppCompatActivity
behind the scenes either way.
App Compat v23.0.1 and the user is running on a Samsung S4 on 5.0.1.
What could be going on here?
EDIT My question is different from the linked "duplicate" question because in that question the OP was not using the Theme.AppCompat theme, while I am using the Theme.AppCompat theme.
Upvotes: 2
Views: 580
Reputation: 2806
If you are using androidx libraries then this answer should help: https://stackoverflow.com/a/53749686/6883143
update from
implementation 'androidx.appcompat:appcompat:1.0.0'
to
implementation 'androidx.appcompat:appcompat:1.0.2'
Upvotes: 0
Reputation: 1791
After a lot of time spent on this, I've conclueed that there is nothing my code is doing wrong and I am going to hope that this is a bug in the older version of the support library and how it interacts with the specific phone.
Hoping that the upgrade to the latest support library version will make this rare issue go away for that one user.
Upvotes: 1