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
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.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--
<style name="Theme.YourAppName" parent="android:Theme.Material.Light.NoActionBar" />
-->
</resources>
Alternative solution.
<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.YOURAPP">
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.YOURAPP" parent="@style/Theme.AppCompat" />
</resources>
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.