A block of ads is displayed, but there is no advertisement itself.
AS writes "Ad finished loading.", But later displays "Ad is not visible. Not refreshing ad."
I tried to change the size - it did not help.
File google-services.json too.
In another application, everything works fine.
Activity code:
MobileAds.initialize(getApplicationContext(), "ca-app-pub-цифры~цифры"); setContentView(R.layout.new_app_widget_configure); AdView mAdView = (AdView) findViewById(R.id.adView); AdRequest adRequest = new AdRequest.Builder() .addTestDevice("цифры") .build(); mAdView.loadAd(adRequest); xml:
<com.google.android.gms.ads.AdView xmlns:ads="http://schemas.android.com/apk/res-auto" android:id="@+id/adView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_alignParentBottom="true" ads:adSize="SMART_BANNER" ads:adUnitId="ca-app-pub-цифры/цифры"> </com.google.android.gms.ads.AdView> Gradle (Project):
buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.0.1' classpath 'com.google.gms:google-services:3.0.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter() maven{ url "https://maven.google.com" } } } task clean(type: Delete) { delete rootProject.buildDir } Gradle (Module) (Part):
dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:25.3.1' compile 'com.google.android.gms:play-services-ads:11.6.0' testCompile 'junit:junit:4.12' compile 'com.android.support.constraint:constraint-layout:1.0.2' } apply plugin: 'com.google.gms.google-services' UPD
It was necessary to do this:
@Override protected void onPause() { AdView mAdView = (AdView) findViewById(R.id.adView); mAdView.pause(); super.onPause(); } @Override protected void onResume() { AdView mAdView = (AdView) findViewById(R.id.adView); super.onResume(); mAdView.resume(); } @Override protected void onStart(){ super.onStart(); MobileAds.initialize(getApplicationContext(), "ca-app-pub-цифры~цифры"); setContentView(R.layout.new_app_widget_configure); AdView mAdView = (AdView) findViewById(R.id.adView); AdRequest adRequest = new AdRequest.Builder() .build(); mAdView.loadAd(adRequest); }