AdMob-Banner does not appear in my app

Good Morning,

I am trying to include a banner in an application via AdMob following what is in: https://developers.google.com/admob/android/quick-start?hl=pt-BR#import_the_mobile_ads_sdk

The problem starts when I try to insert the line below into the dependencies of my gradle. The application gives error and for execution. OBS.: By suggestions of friends I changed the version to the following (implementation 'com.google.android.gms: play-services-ads:12.0.1'), with this change the application ran, but the banner has not yet been displayed.

Implementation 'com.google.android.gms: play-services-ads: 17.0.0 '

Below the inserts I made:

Gradle (app)

    dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation 'com.github.rtoshiro.mflibrary:mflibrary:1.0.0'
    implementation 'com.github.bluejamesbond:textjustify-android:2.1.6'
    implementation 'com.google.android.gms:play-services-ads:12.0.1'
}

AndroidManifest.xml

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

MainActivity.java

MobileAds.initialize(this, "ca-app-pub-3940256099942544~3347511713");
AdView mAdView = (AdView)findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);

Activity_main.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"
            android:layout_marginStart="24dp"
            android:layout_marginLeft="24dp"
            android:layout_marginTop="8dp"
            android:layout_marginEnd="24dp"
            android:layout_marginRight="24dp"
            ads:adSize="BANNER"
            ads:adUnitId="ca-app-pub-3940256099942544/6300978111"
            ads:layout_constraintBottom_toBottomOf="parent"
            ads:layout_constraintEnd_toEndOf="parent"
            ads:layout_constraintHorizontal_bias="0.0"
            ads:layout_constraintStart_toStartOf="parent"
            ads:layout_constraintTop_toBottomOf="@+id/buttonCalcular"
            ads:layout_constraintVertical_bias="1.0"></com.google.android.gms.ads.AdView>

When I'm in design mode of my activity_main.xml the location of the banner appears, however, when running the app The banner is not displayed even with the codes provided by AdMob for testing.

I'm running straight on my mobile for the tests.

 1
Author: Lucas, 2018-10-25

1 answers

Problem solved! The app was shutting down due to a simple error that I hadn't noticed in my Manifest file. The shape that was giving problem and the shape that worked can be viewed below:

Wrong Way:

<meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="[ca-app-pub-3940256099942544~3347511713]"/>

Correct Form:

<meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="ca-app-pub-3940256099942544~3347511713"/>

Hugs!

 0
Author: Lucas, 2018-11-06 16:20:25