Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity in Flutter App

I added payment gateway sdk in my flutter project but when i try to run this project natively on android then app crashes and shows the message "java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity". How to fix this?

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.app">
    <application
        android:label="App"
        android:icon="@mipmap/main_launcher"
        android:usesCleartextTraffic="true">
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"           android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <meta-data
              android:name="io.flutter.embedding.android.SplashScreenDrawable"
              android:resource="@drawable/launch_background"
              />
            <meta-data
                android:name="com.google.firebase.messaging.default_notification_channel_id"
                android:value=""/>
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        <activity
            android:name="com.mastercard.gateway.android.sdk.Gateway3DSecureActivity"
            android:label="@string/gateway_3d_secure_authentication" />
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
</manifest>

styles

<resources>
    <style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
        <item name="android:windowBackground">@drawable/launch_background</item>
    </style>
    <style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
        <item name="android:windowBackground">?android:colorBackground</item>
    </style>
</resources>
like image 399
Mohammed Nabil Avatar asked Oct 20 '25 04:10

Mohammed Nabil


1 Answers

Change your LaunchTheme from

<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">

to

<style name="LaunchTheme" parent="Theme.AppCompat.Light.NoActionBar">
like image 87
Nitish Avatar answered Oct 22 '25 19:10

Nitish



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!