'"No Ad Config." on onAdFailedToLoad() Method While trying to Load Ads
I am trying to load interstitial advertisements for my app. Whenever I try to load these ads I get a Error saying "No Ads Config" from Domain "com.google.android.gms.ads".
Here is the code:
My 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() in 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();
}
});
When I load my ad in a on function it gives me error "No Ad Config."
Log.d("[Ads]","Ad Load State For on(): " + interstitialAd.isLoaded());
if (interstitialAd.isLoaded())
{
interstitialAd.show();
}
Solution 1:[1]
Fixed It and it works.
Found a resource from google. And It cleared all my doubts. For Test Ad Resource Click Me
The Advertisement works in two ways.
- While The App Is In Development.
- While The App Is In Production.
Scenario 1: While the App Is In Devlopment
For this case, we need to use Test Advertisements. Admob and "com.google.android.gms.ads" doesnt allow user to use Advertisements in Development Phase due to false impressions.
To enable Test Advertisement. There are two ways: You can either use google ad unit id's which are available on the link adove. Or You can use your own ad unit id, but you will be needing to register your device as a test device and use your own request configuration. Here is a simple Example: Search for your "Device Id" In "Logcat"
It will look something like
I/ADS: Use Requested Configuration......Arrays.asList("Your device Id will be here");
Then Just Copy Paste This(i can read your mind..)
// Change your Id
RequestConfiguration configuration = new RequestConfiguration.Builder().setTestDeviceIds(Arrays.asList("your device id should go here")).build();
MobileAds.setRequestConfiguration(configuration);
Now just load the ad and it will pop up. Congratz. :)
Scenario 2: While the App Is In Production
This is pretty simple part...
- Just remove the .setTestDeviceIds(Arrays.asList("your device id should go here")) part from the code...
- Link your AdMob App to PlayStore. [Is your app published? Yes...yes...and on...]
- Just opt for ad.
- And check if Ads are enabled in your app settings on play console.
- It should work now. Congratz.
Solution 2:[2]
My mistake: Setting test devices and loading test ads at the same time
Solution: Use one only. By using the test devices with production ad unit id's the error disappeared. Ads are loading again and they are test ads even if you specify the production ad unit id
Solution 3:[3]
This is another method which doesnt require programming.
Go to Admob dashboard > Settings > Test device > Add test device
To find this go to your device settings > Google > Ads > in that you can find your advertising id!
Solution 4:[4]
For FLUTTER apps, using google_mobile_ads there is a slight difference in setting test device. According to documentation you have to updateRequestConfiguration
. Sample code below:
MobileAds.instance.updateRequestConfiguration(RequestConfiguration(testDeviceIds: ["yourdeviceId"]));
You can get the test device by searching for RequestConfiguration in the run output logs.
Solution 5:[5]
This also could happen if your app is uploaded to some store and you didn't set your app-ads.txt correctly.
You should bear in mind that if you are using AdMob test ads, you should add this entry into your app-ads.txt too:
google.com, pub-3940256099942544, DIRECT, f08c47fec0942fa0
Solution 6:[6]
For me, This happens in a development phase, I am using .aab not .apk which Google will re-sign it using their Keystore, hence using my own Keystore will return "Error Code 3, No Ads Config".
Solution 7:[7]
I am using flutter. I just added my device in Admob test devices and it worked. In production I will only remove the test device.
Let me know if I am wrong.
Solution 8:[8]
In my case I forgot to change the app ID for ironsource after I switched from iOS to Android so it kept calling the iOS version of ironsource which was configured to call the wrong Admob ad unit IDs. After fixing the ironsource ID, the correct Admob unit IDs were called and the error was fixed.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Kallos Zsolty |
Solution 3 | Ayush |
Solution 4 | Tonui Nicholus |
Solution 5 | hiddeneyes02 |
Solution 6 | panshen |
Solution 7 | OM KALE |
Solution 8 | Kristof |