Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"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();
                    }
like image 417
Ayush Avatar asked Oct 10 '20 23:10

Ayush


People also ask

Why am I seeing error code 3 No ad Config?

-Make sure you check payment / billing details are current not just in your Admob account, but in your linked Adsense and Google Ad accounts as well. You can see them in Admob > Settings > Account info.

Why is Admob not showing ads?

Have you integrated the Google Mobile Ads SDK correctly? Take a look at the sample apps available for Android and iOS. Sample apps show how to use the Google Mobile Ads SDK to place ads into apps. Ads won't show if you haven't integrated the Google Mobile Ads SDK correctly.


4 Answers

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.

  1. While The App Is In Development.
  2. 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...

  1. Just remove the .setTestDeviceIds(Arrays.asList("your device id should go here")) part from the code...
  2. Link your AdMob App to PlayStore. [Is your app published? Yes...yes...and on...]
  3. Just opt for ad.
  4. And check if Ads are enabled in your app settings on play console.
  5. It should work now. Congratz.
like image 198
Ayush Avatar answered Oct 12 '22 04:10

Ayush


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

like image 14
Kallos Zsolty Avatar answered Oct 12 '22 04:10

Kallos Zsolty


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!

like image 6
Harsh Kothari Avatar answered Oct 12 '22 05:10

Harsh Kothari


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

Soure: https://developers.google.com/admob/android/test-ads

like image 5
hiddeneyes02 Avatar answered Oct 12 '22 05:10

hiddeneyes02