0

No matter what app I write, upon running on my mobiles (Nexus 5 and Note 2), I see errors. It is expected to be a bug in Android Studio.

Detailed explanation: I created two new projects. One with blank activity and one with blank activity+Fragment. Didn't edit anything and tap on Run. Gradle build was successful. It was installed on my device. But when I opened the app on my device, It said "Unfortunately [app name] has stopped."

Android Studio logcat said:

12-05 15:17:27.064  11791-11791/com.widefide.myapplication I/art﹕ Late-enabling -Xcheck:jni
12-05 15:17:27.141  11791-11791/com.widefide.myapplication D/AndroidRuntime﹕ Shutting down VM
12-05 15:17:27.142  11791-11791/com.widefide.myapplication E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.widefide.myapplication, PID: 11791
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.widefide.myapplication/com.widefide.myapplication.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
            at android.app.ActivityThread.access$800(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5221)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
     Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
            at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:151)
            at android.support.v7.app.ActionBarActivityDelegateBase.onCreate(ActionBarActivityDelegateBase.java:138)
            at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:123)
            at com.widefide.myapplication.MainActivity.onCreate(MainActivity.java:13)
            at android.app.Activity.performCreate(Activity.java:5933)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
            at android.app.ActivityThread.access$800(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5221)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

I dug a few similar issues on stackoverflow. One of them pointed to App's theme. I changed that too. But this shouldn't be the issue as Yesterday when I created a blank app. It ran and showed "Hello world" on my phone.

Also, I uninstalled and re-installed Android Studio (saved SDk to another folder), But that also didn't resolve the issue.

Please help me out someone :/ :(

TheOnlyAnil
  • 877
  • 1
  • 15
  • 27

1 Answers1

1

The link posted by @JLONG solved my issue. I wanted to Upvote and comment to thank @iusting But I don't have much reputation on StackOverflow as of now.

The solution is:

  1. Open AndroidManifest.xml
  2. Add android:theme="@style/Theme.AppCompat.Light" in < activity right below android:label...
  3. That's it.
Community
  • 1
  • 1
TheOnlyAnil
  • 877
  • 1
  • 15
  • 27