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"
/>
Related
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.
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" />
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!
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.
i have set test device sill getting live ads..
mAdView = (NativeExpressAdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice("722378CE522E161F0EFAD13A658F5161")
.addTestDevice("048B0A7DC3863535720E0C21AC1C58FD")
.build();
mAdView.loadAd(adRequest);
and my xml code is:
<com.google.android.gms.ads.NativeExpressAdView
android:id="#+id/adView"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_above="#+id/l2"
ads:adSize="360x80"
ads:adUnitId="#string/native_ads"
/>
For getting test native express ads, use following ad unit id-
<string name="native_ad_test_unit_id">ca-app-pub-3940256099942544/6300978111</string>
For getting full width ads, use the FULL_WIDTH constant in the adSize.
For example, your code should be
<com.google.android.gms.ads.NativeExpressAdView
android:id="#+id/adView"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_above="#+id/l2"
ads:adSize="FULL_WIDTHx80"
ads:adUnitId="#string/native_ads"
/>
Use
ca-app-pub-3940256099942544/6300978111
instead of your own Ad unit id.
As described here
https://firebase.google.com/docs/admob/android/native-advanced
it is possible to use
ca-app-pub-3940256099942544/3986624511