问题
So, I have LibGDX app and I'm adding banner like this:
public class AndroidLauncher extends AndroidApplication {
@Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Create the layout
RelativeLayout layout = new RelativeLayout(this);
// Do the stuff that initialize() would do for you
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
// Create the libgdx View
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
View gameView = initializeForView(new Soldiers(), config);
// Create and setup the AdMob view
AdView adView = new AdView(this); // Put in your secret key here
adView.setAdSize(AdSize.SMART_BANNER);
// adView.setAdUnitId("ca-app-pub-3940256099942544/6300978111"); // dummy banner
adView.setAdUnitId("MY_AD_ID"); // Mine
// Create an ad request.
AdRequest.Builder adRequestBuilder = new AdRequest.Builder();
layout.addView(gameView);
// Add the AdMob view
RelativeLayout.LayoutParams adParams =
new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);
adParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
adParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
layout.addView(adView, adParams);
adView.loadAd(adRequestBuilder.build());
setContentView(layout);
}
Instead of "MY_AD_ID" I'm placing my real banner id of course. Then my banner activity in manifest file looks like:
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent" />
And if I'm using that dummy banner id it shows well. I see small banner at the bottom of the screen saying: "AdMob Test Smart Banner ..." and second one (if I slide it) saying "You've loaded a test ad from AdMob. Way to go!" and third one "developers.google.com/admob". So it seems that I'm doing it right. But as soon as I change dummy banner id with real one banner is just now showing up?!
I'm testing on real device (Nexus 5) and working with Android studio.
On AdMob page for my banner says it has 10 network requests but 0 matched requests and matching rate of 0% of course.
My app is published on play store and I linked my ad with that app.
What I'm doing wrong? Since dummy one is working I would say something is wrong with the real banner settings, but what? How can I find out what the problem is?
回答1:
So first of all 0 ads of 10 request is not so representative especially if all of them comes from the same region (like same country).
If AdMob is working with test ad, the implementation should be fine. If the low request / match caused by the lack of ads you can use multiple ad networks.
Also for fresh AdMob accounts it may take some time to delivery the first ad.
来源:https://stackoverflow.com/questions/41791159/my-admob-banner-is-not-showing