最多需要一个带有命名空间“”的元素 <application>,但找到了 2 个

At most one element <application> with namespace '' was expected, but 2 were found

我可以使用 assembleRelease 生成 apk,但是当我 运行 bundleRelease 时它抛出一个错误说

任务“:app:packageReleaseBundle”执行失败。

A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade At most one element with namespace '' was expected, but 2 were found.

> 最多需要一个命名空间为“”的元素,但找到了 2 个。

  ```<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.finder"
      >

        <uses-permission android:name="android.permission.INTERNET" />
        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
        <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

        <application
          android:name=".MainApplication"
          android:networkSecurityConfig="@xml/network_security_config"
          android:label="@string/app_name"
          android:icon="@mipmap/ic_launcher"
          android:roundIcon="@mipmap/ic_launcher_round"
          android:allowBackup="false"
          android:theme="@style/AppTheme"
          android:usesCleartextTraffic="true">
          <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:launchMode="singleTask"
            android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
            android:windowSoftInputMode="adjustResize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="finder" />   
            </intent-filter>
          
          </activity>
          <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
        </application>

        <application>
        <!-- You will only need to add this meta-data tag, but make sure it's a child of application -->
        <meta-data
          android:name="com.google.android.geo.API_KEY"
          android:value="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"/>

        <!-- You will also only need to add this uses-library tag -->
        <uses-library android:name="org.apache.http.legacy" android:required="false"/>
    </application>

    </manifest>```

在您的Manifest文件中,您定义了两次application标签,但通常情况下,一个应用程序在manifest中只有一个application。

您需要将您的清单文件替换为:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.finder"
    >

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

<application
    android:name=".MainApplication"
    android:networkSecurityConfig="@xml/network_security_config"
    android:label="@string/app_name"
    android:icon="@mipmap/ic_launcher"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:allowBackup="false"
    android:theme="@style/AppTheme"
    android:usesCleartextTraffic="true">
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:launchMode="singleTask"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
        android:windowSoftInputMode="adjustResize">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="finder" />
        </intent-filter>

    </activity>
    <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />

    <!-- You will only need to add this meta-data tag, but make sure it's a child of application -->
    <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"/>

    <!-- You will also only need to add this uses-library tag -->
    <uses-library android:name="org.apache.http.legacy" android:required="false"/>
</application>