繁体   English   中英

java.lang.IllegalStateException:您需要在 Flutter App 中使用 Theme.AppCompat 主题(或后代)与此活动

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

我在我的 flutter 项目中添加了支付网关 sdk 但是当我尝试在 android 上本地运行这个项目时,应用程序崩溃并显示消息“java.lang.IllegalStateException:你需要使用这个活动的后代主题。 ”。 如何解决这个问题?

<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>

更改您的LaunchTheme

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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