Q:

java.lang.IllegalStateException on connecting Android device with Android Studio

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????

A:

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" />

