gpt4 book ai didi

android-studio - "No Ad Config."onAdFailedToLoad() 方法尝试加载广告时

转载 作者:行者123 更新时间:2023-12-04 04:27:10 25 4
gpt4 key购买 nike

我正在尝试为我的应用加载插页式广告。每当我尝试加载这些广告时,都会收到来自域“com.google.android.gms.ads”的“无广告配置”错误消息。
这是代码:
我的 AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ayush.torch">


<application

android:allowBackup="true"
android:icon="@drawable/ic_ico"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".main">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="i_have_put_my_app_id_here"/>

</application>

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT" />

</manifest>
onCreate() 在 main.java 中
        
// Creating the InterstitialAd and setting the adUnitId.
interstitialAd = new InterstitialAd(this);
interstitialAd.setAdUnitId("i have also put my interstitial ad id here");


interstitialAd.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
Toast.makeText(main.this, "Ad Loaded", Toast.LENGTH_SHORT).show();
}

@Override
public void onAdFailedToLoad(LoadAdError loadAdError) {
String error = String.format("domain: %s, code: %d, message: %s", loadAdError.getDomain(), loadAdError.getCode(), loadAdError.getMessage());
Toast.makeText(main.this, "onAdFailedToLoad() with error: " + error, Toast.LENGTH_SHORT).show();
}
});
当我在 中加载我的广告时在 功能,它给我错误“无广告配置”。
                    Log.d("[Ads]","Ad Load State For on(): " + interstitialAd.isLoaded());
if (interstitialAd.isLoaded())
{
interstitialAd.show();
}

最佳答案

固定它,它的工作原理。
从谷歌找到了一个资源。它消除了我所有的疑虑。 For Test Ad Resource Click Me
广告以两种方式工作。

  • 应用程序正在开发中。
  • 当应用程序在生产中时。

  • 场景一: 当应用程序处于开发阶段时
    对于这种情况,我们需要使用测试广告。由于错误印象,Admob 和“com.google.android.gms.ads”不允许用户在开发阶段使用广告。
    启用测试广告。有两种方式:
    您可以使用链接 adove 上提供的谷歌广告单元 ID。
    或者
    您可以使用您自己的广告单元 ID,但您需要将您的设备注册为测试设备并使用您自己的请求配置。
    这是一个简单的例子:
    在“Logcat”中搜索您的“设备 ID”
    它看起来像
    I/ADS: Use Requested Configuration......Arrays.asList("Your device Id will be here");
    然后只需复制粘贴这个(我能读懂你的想法..)
    // Change your Id
    RequestConfiguration configuration = new RequestConfiguration.Builder().setTestDeviceIds(Arrays.asList("your device id should go here")).build();
    MobileAds.setRequestConfiguration(configuration);
    现在只需加载广告,它就会弹出。恭喜。 :)

    场景二: 当应用程序在生产中时
    这是非常简单的部分...
  • 只需从代码中删除 .setTestDeviceIds(Arrays.asList("your device id should go here")) 部分...
  • 将您的 AdMob 应用与 PlayStore 相关联。 [你的应用发布了吗?是的......是的......然后......]
  • 只需选择广告。
  • 并检查是否在 Play 控制台的应用设置中启用了广告。
  • 它现在应该可以工作了。恭喜。
  • 关于android-studio - "No Ad Config."onAdFailedToLoad() 方法尝试加载广告时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64299247/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com