AdMob - Banner does not appear in my app

0

Good morning,

I'm trying to include a banner in an app via AdMob by following the instructions at link

The problem starts when I try to insert the line below into the dependencies of my gradle. The application gives error and for execution. NOTE: For 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 insertions 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 the design mode of my activity_main.xml the banner location appears, however, when running the app the banner is not displayed and the codes provided by AdMob for testing.

I'm running right on my phone for testing.

    
asked by anonymous 25.10.2018 / 16:15

1 answer

0

Problem solved! The app was terminating due to a simple error that I had not noticed in my Manifest file. The form that was giving problem and the way it worked can be seen below:

Wrong Form:

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

Right Form:

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

Hugs!

    
06.11.2018 / 17:20