簡體   English   中英

如何正確地將 Admob 添加到 Flutter 項目中?

[英]How to properly add Admob to a Flutter Project?

我有一個使用 Firebase_Admob 包的 Flutter 項目。 對於 iOS,一切都按預期工作,但我的 Android 實例收到以下錯誤...


 * The Google Mobile Ads SDK was initialized incorrectly. AdMob publishers * * App ID inside the AndroidManifest. Google Ad Manager publishers should * ******************************************************************************

這就是我的 AndroidManifest 的樣子......

<application
        android:name="io.flutter.app.FlutterApplication"
        android:label="myfavkpopapp_example"
        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"
            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" />
            <meta-data
                    android:name="com.google.android.gms.ads.APPLICATION_ID"
                    android:value="ca-app-pub-[ADMOB ID]"/>
            <meta-data
                    android:name="com.google.android.gms.version"
                    android:value="@integer/google_play_services_version" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
    </application>

您需要在此處添加您的真實 admob id:

<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-[ADMOB ID]"/>
<meta-data
                android:name="com.google.android.gms.ads.APPLICATION_ID"
                android:value="ca-app-pub-[ADMOB ID]"/>

您將您的應用程序 ID 放入ca-app-pub-[ADMOB ID]並添加互聯網權限

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM