admob is not displaying any ad on android app - android

Admob is not working correctly when putting my banner id, but it's working when adding debug banner id for testing, any help ?
XML code
<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>
Java code
MobileAds.initialize(this, "ca-app-pub-****************");
mAdView = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
and I have these permission in manifist
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
This is the banner ad that I have is it right ?

If the debug ads shows up, then your implementation is correct. Sometimes ads don't show up until they get released (not always true). But yeah it does take a while for google to find the right ads for your app. Be patient

The problem was because I wasn't setting my payment address in admob.

Related

Admob with firebase, only view ads: Nice job! You're displaying a 320x50 test ad from admob

I add admob for my app as guide:
https://firebase.google.com/docs/admob/android/quick-start
and
https://www.youtube.com/watch?v=OLLLRUPICcc&list=PLOU2XLYxmsIKX0pUJV3uqp6N3NeHwHh0c&index=1&spfreload=5
But admob is only view:
Nice job! You're displaying a 320x50 test ad from admob
It does NOT change other ads. Please help me.
Code as below:
In activity at onCreate:
MobileAds.initialize(this, "ca-app-pub-9518053516260440/6844465750");
AdView mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
in xml:
<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="50dp"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-3940256099942544/6300978111">
</com.google.android.gms.ads.AdView>
Acording to the Quickstart
If you haven't created an AdMob account and registered an app yet,
there's no better time than now. If you're just experimenting with the
SDK in a Hello World app, though, you can use this App ID to call the
initialize method: ca-app-pub-3940256099942544~3347511713.
You are using testing appID. To make it work you need to create your own account. Than create application and use your own application ID. This will let you customize what ads should show and it will show actual ads. But for testing you should use this AppID, because you should not click on your own ads.
Fix your appID in xml. But even then it takes some time to actualy start working. It might take about day to start showing real ads.

Ad Mob ads not showing regularly

I'm testing the ad mobs ads on a real device. Sometimes the ads shows up and sometimes it doesn't shows. I've no idea what the problem is.
While testing on a virtual device I used test ads and they always shows up but now I'am using real ads on a device with real app-id and unit-id.
Below is the code I'm using. Any help would be highly appreciated.
Java Code:
MobileAds.initialize(this,"ca-app-pub-8665656565286300~4683225285");
mAdview = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdview.loadAd(adRequest);
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"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-8665656565286300/8888341401"
/>

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 test ad working but not real ad

I added everything to android application as per the instructions from the admob website. On both the emulator and phone i tested my app. The test ads were displaying properly. i generated a signed apk and still it is showing the test ads. what should i do?
here my code:
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="match_parent"
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>
in MainActivity:
MobileAds.initialize(getApplicationContext(), "ca-app-pub-9815982880222619/9339487889");
mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
Please help me!

Integrating admob into Android app

Been having some trouble trying to integrate the admob sdk into my application to display ads. Im using the AdmobSDK version 4.1.0. I've read loads of posts and there seems to be lacking some decent documentation and many discussions on the topic including http://groups.google.com/group/google-admob-ads-sdk/browse_thread/thread/3b885d3fe5bb21a5?pli=1 So far my layout is..
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="#+id/scroll"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/linear"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:focusable="true"
android:focusableInTouchMode="true">
<com.google.ads.AdView
android:id="#+id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adUnitId="MY_PUB_CODE"
ads:adSize="BANNER"/>
</LinearLayout>
</ScrollView>
my androidmanifest.xml contains...
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation"></activity>
<meta-data android:value="MY_PUBLISHER_ID" android:name="ADMOB_PUBLISHER_ID"></meta-data>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
EDIT, UPDATE:
Ok i seem to have gotten admob working on my HTC by adding,
AdView ad = (AdView) findViewById(R.id.ad);
AdRequest r = new AdRequest()
r.addTestDevice("X3XFX518X7DE1FD879XA5XXAX1AX8BXX");
ad.loadAd(r);
however i only recieve a test banner, stating im ready to explore the google app galaxy. When i remove the "addTestDevice" method, the banner/ad does not show up atal and in the log i recieve, "ad not recieved due to lack of inventory" .. Anyone sheed some light on this?
thanks for the help so far!
To your comment, I use this and it works quite well for me. The size is the second param of the AdView constructor.
ad = new AdView(this, AdSize.BANNER, "<ID>");
LinearLayout layout = (LinearLayout) findViewById(R.id.main_admob_layout);
// Add the adView to it
layout.addView(ad);
AdRequest request = new AdRequest();
request.setTesting(TESTING_MODE);
ad.loadAd(request);

Categories

Resources