i've created a AdMob Account and have added my App. I got the my App-ID : ca-app-pub-5XXX84XXX4919XXX~XXX2987XXX ( I changed some numbers to 'X').
Than I create a Bannerview with the ID : ca-app-pub-5XXX84XXX4919XXX/XXX6405XXX ( I changed some numbers to 'X').
final AdView adView = new AdView(appHandler.getActivity());
adView.setAdSize(AdSize.BANNER);
final AdRequest adRequest = new AdRequest.Builder().build();
if (adRequest.isTestDevice(appHandler.getActivity())) {
// Test Device (Android Studio)
if (appHandler.getAdMobileId()==null) {
// No MobileAd Initialization
// Initial the MobileAd with the Test-Id
MobileAds.initialize(appHandler.getActivity(), "ca-app-pub-3940256099942544~3347511713");
appHandler.setAdMobileId("ca-app-pub-3940256099942544~3347511713");
}
// Set the Test AdUnitId to the adView
adView.setAdUnitId("ca-app-pub-3940256099942544/6300978111");
} else {
// Productive Device
if (appHandler.getAdMobileId()==null) {
// No MobileAd Initialization
// Initial the MobileAd App-Id
MobileAds.initialize(appHandler.getActivity(), "ca-app-pub-5XXX84XXX4919XXX~XXX2987XXX");
appHandler.setAdMobileId("ca-app-pub-5XXX84XXX4919XXX~XXX2987XXX");
}
// Set the BannerView AdUnitId to the adView
adView.setAdUnitId("ca-app-pub-5XXX84XXX4919XXX/XXX6405XXX");
}
// Add the adRequest to the adView
adView.loadAd(adRequest);
// Add the View to the GridLayout
innerGrid.addView(adView);
On the Android Studio everything is fine i got the Banner with the "Test Ad" Icon.
On some older Produktiv Devices the Banner is shown ok.
On some newer Devices ( Build.VERSION.SDK_INT >= Build.VERSION_CODES.O ) the banner is not shown with the ErrorCode '1' --> AdRequest.ERROR_CODE_INVALID_REQUEST
I don't know what i am doing wrong.
Thanks.