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);
}
});
}
}
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.
If you create adunit and use it immediately may show this error, try to load ads after 30 minutes or more time.
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.
it's also possible to luck of inventory. I am also face because of of this. failed to load ad : 3
If your AdMob account is only configured for banner ads and you're using interstitial ads, you may get this problem. My 2 cents.
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/
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();
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.
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.
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
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.
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.
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.
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.
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.
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()
}
}
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);
来源:https://stackoverflow.com/questions/26610383/admob-no-fill-from-ad-server-failed-to-load-ad-3