Reputation: 113
Admob shows test banner on emulator, logcat form emulator:
05-03 08:07:44.032 798-798/ru.xxx.xxx I/Ads: Starting ad request.
05-03 08:07:45.572 798-798/ru.xxx.xxx W/Ads: Loading already in progress, saving this object for future refreshes.
05-03 08:07:58.812 798-798/ru.xxx.xxx I/Ads: Scheduling ad refresh 60000 milliseconds from now.
05-03 08:07:58.922 798-798/ru.xxx.xxx I/Ads: Ad finished loading.
but when I run app on device, admob not shows test and real banner. logcat from real device:
05-03 13:17:23.388 28142-28142/ru.xxx.xxx I/Ads: Starting ad request.
05-03 13:17:23.983 28142-28142/ru.xxx.xxx W/Ads: Loading already in progress, saving this object for future refreshes.
05-03 13:17:34.748 28142-28247/ru.xxx.xxx W/Ads: There was a problem getting an ad response. ErrorCode: 0
05-03 13:17:34.749 28142-28142/ru.xxx.xxx W/Ads: Failed to load ad: 0
main activity:
public class AndroidLauncher extends AndroidApplication implements AdsController {
private static final String BANNER_AD_UNIT_ID = "xxx";
AdView bannerAd;
InterstitialAd interstitialAd;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
// Create a gameView and a bannerAd AdView
View gameView = initializeForView(new RunawayCat(this), config);
setupAds();
// Define the layout
RelativeLayout layout = new RelativeLayout(this);
layout.addView(gameView, ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
layout.addView(bannerAd, params);
setContentView(layout);
}
public void setupAds() {
bannerAd = new AdView(this);
bannerAd.setVisibility(View.INVISIBLE);
bannerAd.setAdUnitId(BANNER_AD_UNIT_ID);
bannerAd.setAdSize(AdSize.SMART_BANNER);
AdRequest.Builder builder = new AdRequest.Builder();
AdRequest ad = builder.build();
builder.addTestDevice("xxxx");
bannerAd.loadAd(ad);
}
@Override
public void showBannerAd() {
runOnUiThread(new Runnable() {
@Override
public void run() {
bannerAd.setVisibility(View.VISIBLE);
AdRequest.Builder builder = new AdRequest.Builder();
AdRequest ad = builder.build();
bannerAd.loadAd(ad);
}
});
}
}
manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="ru.romavaleev.runawaycat"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="23" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/GdxTheme" >
<activity
android:name=".AndroidLauncher"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
<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.version" android:value="@integer/google_play_services_version"/>
<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="@android:style/Theme.Translucent" />
</application>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
</manifest>
admob account is not banned, i tested on 3 devices.permissions in manifest is right
Upvotes: 0
Views: 803
Reputation: 6647
Just a guess. It could be you're assigning the testDevice after building the ad?
AdRequest ad = builder.build();
builder.addTestDevice("xxxx");
Swtich the two lines:
builder.addTestDevice("xxxx");
AdRequest ad = builder.build();
Upvotes: 0
Reputation: 14835
Try removing the builder.addTestDevice("xxxx")
Somthing like this
AdRequest.Builder builder = new AdRequest.Builder();
AdRequest ad = builder.build();
bannerAd.loadAd(ad);
I integrate Ads everyday and I have never needed to add the test device, it always shows test ads if you use a test id for Ads
You can use this test banner id
ca-app-pub-3940256099942544/6300978111
and replace this id when you will generate your final APK
Upvotes: 0