1

I recently tried connecting my android phone with android studio to test run my app. Howvever, when the app runs following exception is thrown:

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

The app works fine on the AVD. Min SDK 16 Target SDK 23

My android device has Android Version 4.2.2

I want to use the theme and style that I have created and not this default theme.

Can anyone help????

Vaibhav Agarwal
  • 975
  • 1
  • 7
  • 22

1 Answers1

1

Since you are extending your Activity from AppCompatActivity, you must use theme descendant from Theme.AppCompat.

Thus you should define your theme like this:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- All customizations can go here. -->
</style>

And use it like this:

<activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" />
Rohit Arya
  • 6,751
  • 1
  • 26
  • 40