AdMob No Live-Ads appearing - android

I have made my Application with Android Studio, and now i have a finished app.
I added an AdView to my Application, and used the TestAd-UnitId, and i got test ads. On my Emulator and also on my Mobile Phone. That worked, and i had Test Ads running. Then i created an AdMob account, and added my app in there, created a Bannner ad, like i had in my application, and used the adUnitId, from the AdMob page. But when i ran my Application on my phone i got no ads at all.
In case it matters: The app isn't on the Play Store.
I read that you have to wait several hours, until you get Live-Ads, but i have been waiting for over 12h, and im Still not getting any ads on my Phone.
If you need it, here is my Code:
My AdView:
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
ads:adSize="BANNER"
ads:adUnitId="#string/banner_ad_unit_id"
android:layout_marginBottom="16dp"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginRight="8dp"
app:layout_constraintRight_toRightOf="parent" />
My onCreate Method:
MobileAds.initialize(getApplicationContext(), "ca-app-pub-hiddenhiddenhide~hiddenhide");
AdView ad = (AdView) findViewById(R.id.adView);
AdRequest request = new AdRequest.Builder().build();
ad.loadAd(request);

You need to add this line to the builder.
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
so you need to have something like this:
AdRequest request = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.build();
If you want to use your own mobile phone. you can look for the id in the logcat that needs to be added it will look something like this:
AdRequest request = new AdRequest.Builder()
.addTestDevice("here goes your id of your phone")
.build();
The reason why you need to do this is because when you are developing you can't see adds because the app is not placed in the playstore.
As long as he isn't in the playstore you won't see ads. You can create test-ads with the code is just provided
If you go to production try using this code: (it wil use a testdevice for debugging and developing but it will use real adds for your device as well when in production )
AdRequest adRequest = new AdRequest.Builder()
.build();
if (BuildConfig.DEBUG)
adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("your id goes here")
.build();

Related

ADMOB: Ad is showing on Emulator but not on real device

So, I tried inserting an ad in my app. The test ad is visible on emulator but not on the real device. This question may seem like duplicate but it isn't. I have looked many questions regarding that but they aren't relevant to me. I seem to get everything right on emulator but not on real device. Then I debugged the app on my moto G4 and still no ad.
On my activity:
MobileAds.initialize(this, "ca-app-pub-4408797825766729~9067984003");
AdView mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
On the layout xml:
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
ads:adSize="LARGE_BANNER"
ads:adUnitId="ca-app-pub-4408797825766729/5546529636" />
other than this I didn't code anything related to ads.
If you Have created/added new app on admob it will take time to show ads on your app.
and make sure you have this permission
<uses-permission android:name="android.permission.INTERNET" />

Admob banner doesn't display in production mode

I am integrating admob in my application, using this tutorial. In debug mode, the Admob test banner ad is showing as expected. However, upon removing .addTestDevice("XXXXXXXXXXXXX") and building a signed APK, the real ad doesn't display. Instead the log displays the following:
07-07 16:10:23.743: I/Ads(20143): Starting ad request.
07-07 16:10:23.743: I/Ads(20143): Use AdRequest.Builder.addTestDevice("B2D638A0Bxxx024D83BE163E0E") to get test ads on this device.
Java Code:
AdView adView = (AdView) this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
// Add a test device to show Test Ads
//.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
//.addTestDevice("B2D638A0BEEXXX4024D83BE163E0E")
.build();
// Load ads into Banner Ads
adView.loadAd(adRequest);
XML layout:
<com.google.android.gms.ads.AdView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:id="#+id/adView"
ads:adSize="SMART_BANNER"
ads:adUnitId="ca-app-pub-96XXXXXXXX83/25383XX455" />
Interstitial ads are also integrated into this app and they're displaying perfectly both in debug- and production mode. Why are banners not displaying in production mode?
Found The Solution:
You must create separate ids for banner and Interstitial.While creating an ad-unit a small tab will be opened,if you select banner then an id representing a banner will be created and same goes for Interstitial.I was using Interstitial ID while creating the banner and as a result banner containing Real ads was not showing up.

Android, admob advert is not displaying

I am trying to implement a banner advert in my Android application. I have used Gradle to download the dependencies, etc.
In my activity where I want the advert to be displayed I have:
<com.google.android.gms.ads.AdView
android:id="#+id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="#string/ad_mob_id" />
And ad_mob_id is
ca-app-pub-3940256099942544/6300978111
Which is for test ads, I took that from https://developers.google.com/mobile-ads-sdk/docs/admob/android/quick-start#step_1_modify_the_main_activity_layout
However when I run the activity nothing is displayed and there are no errors/warnings generated.
Am I missing another step?
AdView mAdView = (AdView) getView().findViewById(R.id.adView); // locate the id the banner view
// if you do not use fragments and you are using it directing the remove the getView();
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest); // load it..that's all and you will see logs on it
i took it from the link you posted, it has all you need.

Track Admob Event in Google Analytics

I want to track clicks on an AdMob banners with Google Analytics, but a problem occurs and I don't understand why.
Currently, my AdMob banner is implemented like this:
Layout:
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="#+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adUnitId="YOUR_AD_UNIT_ID"
ads:adSize="BANNER"/>
Java : AdView adView = (AdView)this.findViewById(R.id.adView);
However, the Google demonstration project which shows how to add an AdListener (project available here) does not specify anything in the layout and use the following code to add the banner:
LinearLayout layout = (LinearLayout) findViewById(R.id.leLinearLayoutDeMonChoix);
layout.addView(adView);
But if the implementation described at the beginning is used, the AdListener does not detect any event anymore. Why?
You can find this defective implementation in the following demonstration project: https://drive.google.com/file/d/0B8rE1pbtzNJ1UXg5QllubEFidGc/edit?usp=sharing
I thank you in advance for your time and help.
In the provided implementation you are doing the following:
// Create an ad.
adView = new AdView(this);
// Set the AdListener.
adView.setAdListener(new AdListener() {
/** stuff **/
}
AdView adView = (AdView)this.findViewById(R.id.adView);
// Create an ad request. Check logcat output for the hashed device ID to
// get test ads on a physical device.
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("INSERT_YOUR_HASHED_DEVICE_ID_HERE")
.build();
// Start loading the ad in the background.
adView.loadAd(adRequest);
There is two instances of AdView, and this is your problem.
first one created from inflating your main.xml layout by setContentView(),
second one when you wrote adView = new AdView(this);
You set your listener on the second one, but only the first one is displayed.
It cannot work. :)
Choose one method (create it from layout) or the other (create it from code), but don't mix them up.
If you want to create your ad from layout, do the following:
// Retreive the adView.
AdView adView = (AdView)this.findViewById(R.id.adView);
// Set the AdListener.
adView.setAdListener(new AdListener() {
/** stuff **/
}
// Create an ad request. Check logcat output for the hashed device ID to
// get test ads on a physical device.
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("INSERT_YOUR_HASHED_DEVICE_ID_HERE")
.build();
// Start loading the ad in the background.
adView.loadAd(adRequest);

Admob not working at all:The Google Play services resources were not found.Check your project configuration

I have tried everything, applied every solution I found. Checked googleplayservices many times. Still admob is not working.here I see no need to worry.
Does that mean if I submit my app, admob will work fine after submitting? If not here is my code for admob,how do I fix this?
private AdView adView;
adView = new AdView(this);
adView.setAdSize(AdSize.BANNER);
adView.setAdUnitId("My App Ad Unit ID");
// Add the AdView to the view hierarchy. The view will have no size
// until the ad is loaded.
LinearLayout layout = (LinearLayout) findViewById(R.id.adViewLayout);
layout.addView(adView);
// Create an ad request. Check logcat output for the hashed device ID to
// get test ads on a physical device.
AdRequest adRequest = new AdRequest.Builder()
// .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
// .addTestDevice("52EEC3DAD2FA75F22B44407D19072632")
.build();
// Start loading the ad in the background.
adView.loadAd(adRequest);
XML:
<LinearLayout
android:id="#+id/adViewLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:orientation="vertical" >
</LinearLayout>
This is what the google guys say over it
I keep getting the error 'The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.'
You can safely ignore this message. Your app will still fetch and serve banner ads.
Also this has bee asked several times so just ignore it

Categories

Resources