简体   繁体   中英

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>

Change your LaunchTheme from

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

to

<style name="LaunchTheme" parent="Theme.AppCompat.Light.NoActionBar">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM