You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a runtime exception in chapter 6 v4.0 of the book. Following chapter 6 the app will build and run but it will immediately crash. Looking at Logcat the reason is as follows:
java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
This appears to be a result of the AndroidManifest.xml inheriting the theme from themes.xml
I was able to fix this by making the following changes:
In AndroidManifest.xml define the app theme to AppCompat.
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat"> <!-- Set to this theme -->
And removing the theme definition from themes.xml.
Android Studio Flamingo | 2022.2.1 Patch 2
Build #AI-222.4459.24.2221.10121639, built on May 12, 2023
Runtime version: 17.0.6+0-17.0.6b802.4-9586694 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
The text was updated successfully, but these errors were encountered:
There is a runtime exception in chapter 6 v4.0 of the book. Following chapter 6 the app will build and run but it will immediately crash. Looking at Logcat the reason is as follows:
This appears to be a result of the AndroidManifest.xml inheriting the theme from themes.xml
I was able to fix this by making the following changes:
In AndroidManifest.xml define the app theme to AppCompat.
And removing the theme definition from themes.xml.
Alternative solution.
AndroidManifest.xml:
themes.xml:
More info at: https://stackoverflow.com/a/21815015/1004227
My environment:
The text was updated successfully, but these errors were encountered: