1
Good morning,
I am trying to include a banner in an app via Admob following what: 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 in the dependencies of my Radle. The application gives error and for execution. NOTE: For suggestions from 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'
Down with 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 am in design mode of my activity_main.xml the banner location appears, however, when running the app the banner is not displayed nor with the codes provided by Admob for testing.
I’m running right on my cell for tests.
If you created the banner a little bit, wait a few more hours it should appear. It takes some time until the banner starts to appear.
– Marceloawq
Marceloawq, I have created already 2 days, and even if I set the test banner provided by Admob is not displayed.
– Lucas