无法初始化Admob Banner

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

我尝试使用文档建议的测试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>

android firebase admob
1个回答
0
投票
 MobileAds.initialize(this, "YOUR_ADMOB_APP_ID");

我想你忘了初始化sdk。请使用上面代码中的测试ID。在尝试显示横幅广告之前,您必须初始化admob sdk。

© www.soinside.com 2019 - 2024. All rights reserved.