36

My issue is that ads are not being displayed at all in my app, test mode or not. I am going to keep this question specific to test mode, and once I get that working I will worry about live ads.

Development Information

I am using Eclipse for development.

I have setup ads using Google Play Services and Admob in my Android app, as described in the online documentation provided by Google.

I have added my device ID using addTestDevice("xxxxxxxxxxxxxxxx"), and have checked the hashed device ID a number of times to be sure it is correct.

The Issue (see below for log info)

When I run the application on my device, no ads are displayed at all. This happens even when I have added my device as a test device.

I have searched high and low, and turned up many similar issues, but am yet to find an answer to this specific problem.

LogCat Output

10-28 13:56:41.659: I/Ads(1704): Starting ad request.
10-28 13:56:42.187: I/Ads(1704): No fill from ad server.
10-28 13:56:42.187: W/Ads(1704): Failed to load ad: 3
10-28 13:56:42.199: W/Ads(1704): No GMSG handler found for GMSG: gmsg://mobileads.google.com/jsLoaded?google.afma.Notify_dt=1414504602197

My Activity

   package bb.hoppingbird;

    import org.cocos2d.layers.CCScene;
    import org.cocos2d.nodes.CCDirector;
    import org.cocos2d.opengl.CCGLSurfaceView;

    import com.google.android.gms.ads.AdListener;
    import com.google.android.gms.ads.AdRequest;
    import com.google.android.gms.ads.AdSize;
    import com.google.android.gms.ads.AdView;
    import com.google.android.gms.ads.InterstitialAd;

    import android.app.Activity;
    import android.content.SharedPreferences;
    import android.media.MediaPlayer;
    import android.os.Bundle;
    import android.support.v4.view.ViewPager.LayoutParams;
    import android.util.DisplayMetrics;
    import android.view.KeyEvent;
    import android.widget.RelativeLayout;
    import android.widget.Toast;

    public class MainActivity extends Activity {

    private CCGLSurfaceView mGLSurfaceView;

    //<!-- Admob Ads Using Google Play Services SDK -->
    private static final String AD_UNIT_ID = "ca-app-pub-xxxxxxxxxxxxxxxxxxxx";
    private static final String AD_INTERSTITIAL_UNIT_ID = "ca-app-pub-xxxxxxxxxxxxxxxxxxxx";


    /** The Admob ad. */
    private InterstitialAd interstitialAd = null;
    public AdView adView = null;

    public static MainActivity app;

    public void onCreate(Bundle savedInstanceState)
    {
        app = this;

        super.onCreate(savedInstanceState);

        // set view
        mGLSurfaceView = new CCGLSurfaceView(this);


        //Ads ----------------
        // Create the adView
        RelativeLayout layout = new RelativeLayout(this);
        layout.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

        //<!-- Ads Using Google Play Services SDK -->
        adView = new AdView(this);
        adView.setAdSize(AdSize.SMART_BANNER);
        adView.setAdUnitId(AD_UNIT_ID);

        // Add the adView to it
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
                LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT);
        params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
        params.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE);

        adView.setLayoutParams(params);

        layout.addView(mGLSurfaceView);
        layout.addView(adView);

        setContentView(layout);
        //New AdRequest 
        AdRequest adRequest = new AdRequest.Builder()
        .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
        .addTestDevice("0D47C6944503F0284666D16BB79BF684")
        .build();

    // Start loading the ad in the background.
    adView.loadAd(adRequest);


        //-----------------------------------------------------Interstitial Add
        // Create an Interstitial ad.
        interstitialAd = new InterstitialAd(this);
        interstitialAd.setAdUnitId(AD_INTERSTITIAL_UNIT_ID);
        interstitialAd.setAdListener(new AdListener() {
              @Override
              public void onAdLoaded() {
                interstitialAd.show();
              }

              @Override
              public void onAdFailedToLoad(int errorCode) {
                  Toast.makeText(getApplicationContext(), "Interstitial Ads loading failed", Toast.LENGTH_SHORT).show();
              }
        });
         // Load the interstitial ad.
        //showInterstitialAds();

        //----------------------
        // set director
        CCDirector director = CCDirector.sharedDirector();
        director.attachInView(mGLSurfaceView);
        director.setAnimationInterval(1/60);

        // get display info
        DisplayMetrics displayMetrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
        G.display_w = displayMetrics.widthPixels;
        G.display_h = displayMetrics.heightPixels;
        G.scale = Math.max(G.display_w/1280.0f, G.display_h/800.0f);
        G.width = G.display_w / G.scale;
        G.height = G.display_h / G.scale;

        // get data
        SharedPreferences sp = CCDirector.sharedDirector().getActivity().getSharedPreferences("GameInfo", 0);
        G.music = sp.getBoolean("music", true);
        G.sound = sp.getBoolean("sound", true);

        // create sound
        G.soundMenu = MediaPlayer.create(this, R.raw.menu);
        G.soundMenu.setLooping(true);
        G.soundGame = MediaPlayer.create(this, R.raw.game);
        G.soundGame.setLooping(true);
        G.soundCollide = MediaPlayer.create(this, R.raw.collide);
        G.soundJump = MediaPlayer.create(this, R.raw.jump);
        G.soundLongJump = MediaPlayer.create(this, R.raw.long_jump);
        G.soundSpeedDown = MediaPlayer.create(this, R.raw.speed_down);
        G.soundSpeedUp = MediaPlayer.create(this, R.raw.speed_up);
        G.soundDirection = MediaPlayer.create(this, R.raw.direction_sign);
        G.soundClick = MediaPlayer.create(this, R.raw.menu_click);
        G.soundCollect = MediaPlayer.create(this, R.raw.collect);
        G.bgSound = G.soundMenu;

        // show menu
        CCScene scene = CCScene.node();
        scene.addChild(new MenuLayer(true));
        director.runWithScene(scene);
    }  

    @Override
    public void onPause()
    {
        if (adView != null) {
              adView.pause();
            }

        super.onPause();
        G.bgSound.pause();
        CCDirector.sharedDirector().onPause();
    }

    @Override
    public void onResume()
    {
        super.onResume();

        if (adView != null) {
            adView.resume();
          }

        if( G.music ) G.bgSound.start();

        CCDirector.sharedDirector().onResume();
    }

    @Override
    public void onDestroy()
    {
        // Destroy the AdView.
        if (adView != null) {
          adView.destroy();
        }

        super.onDestroy();
        G.bgSound.pause();
        CCDirector.sharedDirector().end();
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event)
    {
        if( keyCode == KeyEvent.KEYCODE_BACK )
        {
            CCDirector.sharedDirector().onKeyDown(event);
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }

    public void showInterstitialAds()
    {
        runOnUiThread(new Runnable() {
            public void run() {
                 AdRequest interstitialAdRequest = new AdRequest.Builder().build();
                 interstitialAd.loadAd(interstitialAdRequest);
            }
        });
    }
}
Vhycko Mayaut
  • 361
  • 1
  • 3
  • 5

18 Answers18

13

If you create adunit and use it immediately may show this error, try to load ads after 30 minutes or more time.

kalandar
  • 793
  • 6
  • 13
  • It may even take a few hours (with new ad units, or perhaps even a new AdMob app). – caw Mar 15 '21 at 08:37
11

The issues comes only if that particular app is suspended from playstore. Maybe you can try changing the package name and and also with new Admob Id.There is a chance that particular admob id can also be suspended due to compliances.

Jared Burrows
  • 54,294
  • 25
  • 151
  • 185
pradeep.k
  • 1,391
  • 2
  • 9
  • 13
  • I agree with this answer, just rename your package, it will work 100%. – Ayaz Alifov Jan 30 '15 at 09:37
  • 2
    I just encountered this today. My app was suspended.. Change also the app name - `TestApp` – mboy Mar 05 '15 at 01:48
  • 4
    This is wrong. The reason might be that the app is suspended, but there are other possible reasons. For instance, creating another app unit in the admob interface might help. – Damnum Jul 19 '15 at 19:42
  • 15
    Unfortunately "The issues comes only if that particular app is suspended from playstore." is not true. My app and admob account are fine, in fact ~37% of customers are receiving ads. This was sudden, overnight, down from ~100% without even updating my app on the Google Play. My 2 test devices however are not displaying the ads and are getting the code 3 error also. – John Ashmore Aug 18 '15 at 05:27
  • 9
    my app not suspended still i am facing same issue. so i think suspended is not reason for this error. – Suresh Kerai Nov 26 '17 at 04:26
  • @JohnAshmore Same thing is happening with me, is there any work around for that ? How did you solve this ? – Smeet Nov 29 '18 at 11:12
7

You need to use ID that Google provide for you for current test device. You can find it in logcat, just find something like this:

Ads: Use AdRequest.Builder.addTestDevice("903A70A3D439E256BAED43E65A79928E") to get test ads on this device.
Trancer
  • 765
  • 2
  • 8
  • 23
3

it's also possible to luck of inventory. I am also face because of of this. failed to load ad : 3

Community
  • 1
  • 1
Suresh Kerai
  • 891
  • 1
  • 6
  • 20
3

In my case I found that my billing address was not verified and ads were blocked. Verify billing address it will automatically get fixed. https://www.google.com/adsense/

Gkapoor
  • 840
  • 1
  • 13
  • 27
  • This looks like what is happening for me as well. The test ad units display. I had a previous app with this gmail address that never hit the payout threshold. I don't remember it being adsense, but maybe it was? The new one that I am currently using is admob, and those ads are reliably getting "failed to load code 3". At my adsense home page it says "Your ad units are not displaying because you haven't yet verified your address (PIN)." Going to try resending the PIN. – user1978019 Oct 24 '20 at 05:04
2

If your AdMob account is only configured for banner ads and you're using interstitial ads, you may get this problem. My 2 cents.

Tushar Nallan
  • 784
  • 6
  • 16
2

Basically just try pass your test device id to adBuilder :

/** adRequest Object For test device */
AdRequest adRequest = new AdRequest.Builder().addTestDevice("TEST_DEVICE_ID").build();

/** adRequest Object For Production Device*/
AdRequest adRequest = new AdRequest.Builder().build();

You can find your test divece id in logCat after without test divece id adBuilder request:

I/Ads: Use AdRequest.Builder.addTestDevice("TEST_DEVICE_ID") to get test ads on this device.

1

If you app support Designed for Families.

Bundle extras = new Bundle();
extras.putBoolean("is_designed_for_families", true);

AdRequest request = new AdRequest.Builder()
        .addNetworkExtrasBundle(AdMobAdapter.class, extras)
        .build();
Orgatres
  • 117
  • 1
  • 11
  • 1
    I created my banner ad and also verify my payment information, and after 2 days i test my ad and it gives me the error that Error code 3 No add fill from the server... – Asad Mukhtar Jun 14 '18 at 20:04
  • @AsadMukhtar Hi, I am having the same issue, i created the banner ad and also have everything verified and after 2 days i am not getting ads(no ads not even test ads are showing). Same msg "Error code 3 No add fill from the server" could you please _/\\_ HELP? What happened in your case?, how did you solve it? or was this temporary? – Diljeet Aug 01 '18 at 08:25
  • Same issue, but noticed it only worked ok depending on device/screen orientation! Pixel 3 landscape OK, portrait KO. Then on Doogee, landscape KO, portrait OK !? Using smartbanner or banner makes very little difference. – 3c71 May 08 '19 at 13:28
1

I was testing on Galaxy S4, later my friend tested on Note 2 and it did not show the banner ad. Hence the problem was test device Id. If you are testing then make sure the test device ID is of the device you are testing on.

ahmadalibaloch
  • 5,851
  • 2
  • 50
  • 59
0

I had this problem too. It wasn't until I went to Admob.com and "manually" added my app so I could get my "Ad Unit Id". I put this Ad Unit Id string as the argument my adView.setAdUnitId call. Then I installed and opened the "release" APK I generated via Eclipse. File > Export > Export Android Application

Red Cricket
  • 9,762
  • 21
  • 81
  • 166
0

I had this issue as well today. My app was not suspended, but the apk name change did work. We had renamed a test app to release it to production; we changed the apk name as a result. This screwed up our ad fill on both MoPub and Admob.

Adam Link
  • 2,783
  • 4
  • 30
  • 44
0

Ads are disabled from Admob server, your code is ok, try to change the package name, and see if ads are displayed. Then contact admob to see the problem.

Safwan Hijazi
  • 2,089
  • 2
  • 17
  • 29
0

In my case this was the error as result of requesting a geo-restricted ad from a region that's not supported for that ad. If I hardcoded the location for the ad request bundle to be inside the acceptable region, or not include a location in the request at all, the ad was rendered just fine; otherwise I had the same error as OP in console.

raptors
  • 232
  • 1
  • 5
  • 12
0

In my case my banner ads have response code 3 on some devices with high API and especially with wide screen (I have used smart banner size), changing dependcy from com.google.android.gms.ads to com.google.firebase:firebase-ads (In case you are using Firebase) solved my problem.

Pavel Poley
  • 5,307
  • 4
  • 35
  • 66
0

In my case I was testing using an emulator and getting the same error. After change to a phone everything works.

Try another test device.

Eneas Gesing
  • 533
  • 7
  • 10
0

It might be because you're not waiting for the ad to load.

For me implementing the AdLoaded method of the AdListener did the job.

    mAdInterstitial.loadAd(AdRequest.Builder().addTestDevice("XXXXXXX").build())
    mAdInterstitial.adListener = object : AdListener() {
        override fun onAdLoaded() {
            mAdInterstitial.show()
        }
    }
patricK
  • 1,045
  • 11
  • 27
Phil C
  • 1
  • 6
0

I was following along a youtube tutorial and the guy was using a "Banner" at first and switched to "SMART_BANNER". So I thought I could also use the smart banner. Unfortunately this was the mistake, I changed the adsize and it worked. You also might have a different adSize.

 <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        app:adSize="BANNER"
        app:adUnitId="ca-app-pub-3940256099942544/6300978111"></com.google.android.gms.ads.AdView>

Code used in the Activity:

MobileAds.initialize(this) {}
var mAdView = findViewById<AdView>(R.id.adView)

val adRequest = AdRequest.Builder().build()
mAdView.loadAd(adRequest)
shiteatlife
  • 57
  • 2
  • 12
-4

try this:

MobileAds.initialize(this, getString(R.string.admob_app_id));
AdView mAdView = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();      
mAdView.loadAd(adRequest);
Paul Roub
  • 36,322
  • 27
  • 84
  • 93