【问题标题】:How do I resolve this firebase messaging error in the androidmanifest.xml of my flutter application?如何解决我的颤振应用程序的 androidmanifest.xml 中的这个 firebase 消息传递错误?
【发布时间】:2020-10-21 12:50:31
【问题描述】:

我按照https://pub.dev/packages/firebase_messaging#-readme-tab- 此处的步骤在我的模拟器中显示通知,但在颤振终端中出现此错误,

出了什么问题: 任务 ':app:generateDebugBuildConfig' 执行失败。 org.xml.sax.SAXParseException; systemId:文件:/C:/Users/steve/Repos/off-top-flutter/android/app/src/main/AndroidManifest.xml;行号:17;列号:44;已为元素“application”指定了绑定到命名空间“http://schemas.android.com/apk/res/android”的属性“name”。>

下面是我在 AndroidManifest.xml 中的代码:

<application
        android:name=".Application"
        android:name="io.flutter.app.FlutterApplication"
        android:label="off_top_mobile"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- This keeps the window background of the activity showing
                 until Flutter renders its first frame. It can be removed if
                 there is no splash screen (such as the default splash screen
                 defined in @style/LaunchTheme). -->
            <meta-data
                android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
                android:value="true" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>


            <intent-filter>
                <action android:name="FLUTTER_NOTIFICATION_CLICK" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>

        </activity>

    </application>

【问题讨论】:

    标签: android firebase flutter firebase-cloud-messaging


    【解决方案1】:

    您在应用程序元素中指定了两次android:name 属性:

    <application
            android:name=".Application"
            android:name="io.flutter.app.FlutterApplication"
    

    你只能拥有一个。您可能只想保留您开始使用的那个,而不是您添加的那个。

    【讨论】:

    • 最初我只有 android:name="io.flutter.app.FlutterApplication",应用程序运行良好,但我想添加来自 firebase 的消息通知。从教程中,它说要添加,android:name =“.Application”。有没有办法同时拥有或合并它们?
    • 不,您最多需要一个。对于消息传递的目的,该属性的值无关紧要。它应该正确识别您的应用程序类(如果有的话)。
    猜你喜欢
    • 2021-07-02
    • 2021-04-18
    • 2021-04-19
    • 2023-02-16
    • 2019-06-19
    • 2020-10-15
    • 2020-06-27
    • 2019-06-02
    • 2018-09-30
    相关资源
    最近更新 更多