如何在flutter应用程序的androidmanifest.xml中解决此Firebase消息传递错误?

时间:2020-07-01 06:06:23

标签: android firebase flutter firebase-cloud-messaging

我正在按照https://pub.dev/packages/firebase_messaging#-readme-tab-的步骤在模拟器中显示通知,但在flutter终端中却收到此错误,

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

下面是我在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>

1 个答案:

答案 0 :(得分:0)

您在application元素中两次指定了android:name属性:

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

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