Admob ads are not displayed

Good afternoon!

I'm trying to add ads to my app, all according to the instructions https://developers.google.com/mobile-ads-sdk/docs/admob/android/quick-start.

First, I added a line to build.gradle (module: app)

compile 'com.google.android.gms:play-services:7.0.0'

Changed the manifest

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

+

<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" />

Added

<string name="banner_ad_unit_id">ca-app-pub-3940256099942544/6300978111</string>

Changed.xml file

xmlns:ads="http://schemas.android.com/apk/res-auto"

+

 <com.google.android.gms.ads.AdView
    android:id="@+id/adView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_alignParentBottom="true"
    ads:adSize="BANNER"
    ads:adUnitId="@string/banner_ad_unit_id">
</com.google.android.gms.ads.AdView>

Added to the code activiti:

 import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;

+

AdView mAdView = (AdView) findViewById(R.id.adView);
    AdRequest adRequest = new AdRequest.Builder().build();
    mAdView.loadAd(adRequest);

When rendering in android studio, you can see the place under the banner, but when you launch the app, there is no banner

05-05 15:14:49.746    1386-1386/su.worldbest.bbdd W/GooglePlayServicesUtil﹕ Google Play services is missing.
05-05 15:14:49.770    1386-1386/su.worldbest.bbdd W/GooglePlayServicesUtil﹕ Google Play services is missing.
05-05 15:14:49.790    1386-1389/su.worldbest.bbdd D/dalvikvm﹕ GC_CONCURRENT freed 208K, 3% free 8742K/8976K, paused 4ms+2ms, total 14ms
05-05 15:14:49.802    1386-1386/su.worldbest.bbdd I/Ads﹕ CsiReporterFactory: CSI is not enabled. No CSI reporter created.
05-05 15:14:49.814    1386-1386/su.worldbest.bbdd I/Ads﹕ Starting ad request.
05-05 15:14:49.818    1386-1386/su.worldbest.bbdd I/Ads﹕ Use AdRequest.Builder.addTestDevice("D5C4A6CB58FB68100CD3CBDF39CB8F22") to get test ads on this device.
05-05 15:14:49.870    1386-1398/su.worldbest.bbdd D/dalvikvm﹕ DexOpt: --- BEGIN 'ads-1062427778.jar' (bootstrap=0) ---
05-05 15:14:49.894    1386-1398/su.worldbest.bbdd D/dalvikvm﹕ DexOpt: --- END 'ads-1062427778.jar' (success) ---
05-05 15:14:49.894    1386-1398/su.worldbest.bbdd D/dalvikvm﹕ DEX prep '/data/data/su.worldbest.bbdd/cache/ads-1062427778.jar': unzip in 0ms, rewrite 22ms
05-05 15:14:50.330    1386-1405/su.worldbest.bbdd I/Ads﹕ CsiReporterFactory: CSI is not enabled. No CSI reporter created.

The banner is not visible either on the emulator or on the real device. What to do?

Author: Eugene Strelnikov, 2015-05-05

2 answers

At first, I could not understand why the banner was not visible, although I did everything according to the instructions!

It turned out that the banner is often not visible only because, banal, does not fit (in size) in the space that you have assigned it. And, mostly, in width!

You need to look at the dimensions and constraints (especially padding 's) of all the LinearLayouts, GridLayouts, scrollviews, etc. covering it, i.e. view the dimensions (again: especially padding' s) of all parent Layouts throughout the hierarchy of the overall page layout (*. xml)

Unfortunately, no warnings (messages) on this account are made by Android Studio (3.0.1) so far. But you should!!! It's time! )

 0
Author: user_MGU, 2017-12-10 06:40:47

I had the same thing. Removing the internal markup of the file {[1] helped]} Delete all lines:

android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"

And.... Hooray! the banner appears! =)

 2
Author: Евгений, 2015-10-08 20:08:05