在flutter中添加google_mobile_ads sdk后出错

问题描述 投票:0回答:1

我在我的 flutter 项目中添加了

google_mobile_ads
sdk
v5.0.0
。现在,当我运行该项目时,出现以下错误

X:\<project-name>\android\app\src\debug\AndroidManifest.xml:92:13-59 Error:
    Attribute property#android.adservices.AD_SERVICES_CONFIG@resource value=(@xml/gma_ad_services_config) from [com.google.android.gms:play-services-ads-lite:23.0.0] AndroidManifest.xml:92:13-59
    is also present at [com.google.android.gms:play-services-measurement-api:21.5.1] AndroidManifest.xml:32:13-58 value=(@xml/ga_ad_services_config).
    Suggestion: add 'tools:replace="android:resource"' to <property> element at AndroidManifest.xml to override.

我尝试过使用4.0.0版本,但出现同样的错误。 另外,我的

property
目前没有
AndroidManifest.xml
标签。

以下是我的 AndroidManifest.xml 位于 ' ndroid pp\src\main\AndroidManifest.xml'

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="<package-name>">
   <uses-permission android:name="android.permission.INTERNET"/>
   <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
   <uses-permission android:name="com.android.vending.BILLING"/>
   
   <application
        android:label="${appName}"
        android:name="${applicationName}"
        android:icon="@mipmap/launcher_icon"
        >
        <activity
            android:name=".MainActivity"
            android:exported="true"
            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">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />            
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="<id>"/>
    </application>
</manifest>
android flutter dart admob google-mobile-ads
1个回答
0
投票

您也应该在这里使用您的应用程序

<meta-data
        android:name="com.google.android.gms.ads.APPLICATION_ID"
        android:value="<id>"/>
© www.soinside.com 2019 - 2024. All rights reserved.