无法初始化Admob横幅

时间:2019-04-01 18:59:42

标签: android firebase admob

我尝试使用文档建议的测试ID初始化AdMob横幅广告,但是在运行应用程序时出现这些错误。 我不明白我失败了。我试图按照指南进行操作,但它们过旧或根本无法工作。

   04-01 18:47:57.454 3538-3538/it.bluebait.adsdemo E/AndroidRuntime: FATAL EXCEPTION: main
Process: it.bluebait.adsdemo, PID: 3538
java.lang.RuntimeException: Unable to get provider com.google.android.gms.ads.MobileAdsInitProvider: java.lang.IllegalStateException: 

******************************************************************************
* The Google Mobile Ads SDK was initialized incorrectly. AdMob publishers    *
* should follow the instructions here: to add a valid  *
* App ID inside the AndroidManifest. Google Ad Manager publishers should     *
* follow instructions here:                       *
******************************************************************************


    at android.app.ActivityThread.installProvider(ActivityThread.java:5002)
    at android.app.ActivityThread.installContentProviders(ActivityThread.java:4594)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4534)
    at android.app.ActivityThread.access$1500(ActivityThread.java:151)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5254)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
 Caused by: java.lang.IllegalStateException: 

清单

<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="it.bluebait.adsdemo">
<uses-permission android:name="android.permission.INTERNET" />
<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>


        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="ca-app-pub-3940256099942544~3347511713"/>

    </activity>
</application>

1 个答案:

答案 0 :(得分:0)

 MobileAds.initialize(this, "YOUR_ADMOB_APP_ID");

我认为您忘记了初始化SDK。请在上面的代码中使用测试ID。 您必须先初始化admob sdk,然后才能展示横幅广告。