Android app builds ok but crashes on launch (Cordova)

This was previously building/running fine, but now using cordova-android 13.0 (previously 9) and getting a run-time error. Provided details below of the error and some relevant files. Let me know if any more information would be useful.

**java.lang.RuntimeException: Unable to start activity ComponentInfo{com.primetics.genware/com.primetics.genware.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.**

Main Activity looks like this

*package com.primetics.genware;*

*import android.os.Bundle;*

*import org.apache.cordova.*;*

*public class MainActivity extends CordovaActivity*
*{*
*    @Override*
*    public void onCreate(Bundle savedInstanceState)*
*    {*
*        super.onCreate(savedInstanceState);*

*        // enable Cordova apps to be started in the background*
*        Bundle extras = getIntent().getExtras();*
*        if (extras != null && extras.getBoolean("cdvStartInBackground", false)) {*
*            moveTaskToBack(true);*
*        }*

*        // Set by <content src="index.html" /> in config.xml*
*        loadUrl(launchUrl);*
*    }*
*}*

Android-manifest.xml

*<?xml version='1.0' encoding='utf-8'?>*
*<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" xmlns:android="http://schemas.android.com/apk/res/android">*
*    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />*
*    <uses-permission android:name="android.permission.INTERNET" />*
*    <application android:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:networkSecurityConfig="@xml/network_security_config" android:supportsRtl="true">*
*        <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" android:exported="true" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:screenOrientation="portrait" android:theme="@android:style/Theme.Translucent" android:windowSoftInputMode="adjustResize">*
*            <intent-filter android:label="@string/launcher_name">*
*                <action android:name="android.intent.action.MAIN" />*
*                <category android:name="android.intent.category.LAUNCHER" />*
*            </intent-filter>*
*        </activity>*
*        <provider android:authorities="${applicationId}.cdv.core.file.provider" android:exported="false" android:grantUriPermissions="true" android:name="androidx.core.content.FileProvider">*
*            <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/cdv_core_file_provider_paths" />*
*        </provider>*
*    </application>*
*    <queries>*
*        <intent>*
*            <action android:name="android.media.action.IMAGE_CAPTURE" />*
*        </intent>*
*    </queries>*
*</manifest>*

gradle.properties


*org.gradle.jvmargs=-Xmx2048m*
*android.useAndroidX=true*
*android.enableJetifier=true*

Please update your post with proper code blocks so we can easily read it.

With some Googling, it looks like this theme is invalid that is set in your AndroidManifest.xml.

For a new Cordova app, looks like it has (source):

android:theme="@style/Theme.App.SplashScreen"

which is declared in android/res/values/themes.xml (source):

<resources>
    <style name="Theme.App.SplashScreen" parent="Theme.SplashScreen.IconBackground">
      <!-- Optional: Set the splash screen background. (Default: #FFFFFF) -->
      <item name="windowSplashScreenBackground">@color/cdv_splashscreen_background</item>

      <!-- Required: Add either a drawable or an animated drawable -->
      <item name="windowSplashScreenAnimatedIcon">@drawable/ic_cdv_splashscreen</item>

      <!-- Required: For animated icons -->
      <item name="windowSplashScreenAnimationDuration">200</item>

      <!-- Required: Set the theme of the Activity that directly follows your splash screen. -->
      <item name="postSplashScreenTheme">@style/Theme.AppCompat.NoActionBar</item>
    </style>
</resources>

For a Capacitor app, we have:

android:theme="@style/AppTheme.NoActionBarLaunch"

Then in android/app/src/main/res/values/styles.xml we have:

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

    <style name="AppTheme.NoActionBar" parent="Theme.AppCompat.DayNight.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="android:background">@null</item>
    </style>


    <style name="AppTheme.NoActionBarLaunch" parent="Theme.SplashScreen">
        <item name="android:background">@drawable/splash</item>
    </style>
</resources>

Resources

Thanks for that. I’ve modified my config.xml to reference the correct them and will re-build the app and see if that work.

        <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application/activity" xmlns:android="http://schemas.android.com/apk/res/android">
            <activity android:theme="@android:style/Theme.App.SplashScreen" />
        </edit-config>