Admob test ad working but not real ad - android

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!

Related

admob is not displaying any ad on android app

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.

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" />

Why admob ads are not displaying?

I'm trying to place ads in my android app but facing one issue.
The logcat is saying
Failed to connect to remote ad service.
Could not start the ad request service.
Failed to load ad: 0
activity_main.xml -
<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_mainpg">
</com.google.android.gms.ads.AdView>
java file -
MobileAds.initialize(getApplicationContext(), "ca-app-pub-9368742373801645~2595542217");
AdView mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR) // All emulators
.addTestDevice("3EF57886E34C0084")
.build();
mAdView.loadAd(adRequest);
I've tried running my app on emulator instead of real device but still ads are not loading. Everytime I get this error failed to load ad: 0
What mistake did I make in the implementation ? Any help would be appreciated.

Showing three admob ads in TabView

I need to show one banner ad per one tabview, so I changes the android:id (check below code) and the add is successfully appears in all required tabs. Is it ok or its against Google's Terms of Service. Please tell me if any other way to show the ads
XML
First Layout
<com.google.android.gms.ads.AdView android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="#string/admobid"
ads:adSize="SMART_BANNER"/>
Second
<com.google.android.gms.ads.AdView android:id="#+id/adView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="#string/admobid"
ads:adSize="SMART_BANNER"/>
Third one
<com.google.android.gms.ads.AdView android:id="#+id/adView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="#string/admobid"
ads:adSize="SMART_BANNER"/>
Java code:
adView = (AdView)this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("356d67mydeviceid")
.build();
adView.loadAd(adRequest);
adView2 = (AdView)this.findViewById(R.id.adView2);
AdRequest adRequest2 = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("356d67mydeviceid")
.build();
adView2.loadAd(adRequest2);
adView3 = (AdView)this.findViewById(R.id.adView3);
AdRequest adRequest3 = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("356d67mydeviceid")
.build();
adView3.loadAd(adRequest3);
Output
https://lh5.googleusercontent.com/-CPKhDMkAwnU/U5_PtY4U_vI/AAAAAAAAADc/tUeQZTwnBdo/s320/tabview.png
While perhaps not against the spirit of the Admob policy it is probably technically agsint the letter of it. You are probably better off creating a single AdView and positioning it above or below your TabView.
Place your tabview and ad banner into the same layout

Categories

Resources