代码之家  ›  专栏  ›  技术社区  ›  Charles Jr

如何正确地将Admob添加到flatter项目中?

  •  0
  • Charles Jr  · 技术社区  · 6 年前

    我有一个flatter项目,它使用Firebase\u Admob包。在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>
    
    1 回复  |  直到 6 年前
        1
  •  1
  •   user3234870    6 年前

    您需要在此处添加真正的admob id:

    <meta-data
    android:name="com.google.android.gms.ads.APPLICATION_ID"
    android:value="ca-app-pub-[ADMOB ID]"/>
    
        2
  •  0
  •   m.samil58    4 年前
    <meta-data
                    android:name="com.google.android.gms.ads.APPLICATION_ID"
                    android:value="ca-app-pub-[ADMOB ID]"/>
    

    ca-app-pub-[ADMOB ID] 并添加internet权限