How to test ads if AdView failed to load 3 - android

I use AdViews in my app in almost every activity.
The xml im using is:
<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_centerInParent="true"
ads:adSize="SMART_BANNER"
ads:adUnitId="#string/Banner_Ads"
ads:layout_constraintEnd_toEndOf="parent"
ads:layout_constraintStart_toStartOf="parent"
ads:layout_constraintTop_toTopOf="parent"
app:gnt_template_type="#layout/gnt_small_template_view" />
I did every thing I could to test it by either using Test ID for the ads or by setting TestDeviceID and everything works good.
How can I be sure that it will work with real ads? when i did a single check of my app before distribution it gives me ad failed to load : 3.
Yes, I read that it can happen if I created ad unit recently and that it might might take time or that it means that my code is correct but there are no ads. But what does it means no ads? isnt AdView meant to be for ads?
Thank you

Related

Ads do not show in my application

I don't know what I am missing, currently I have:
build gradle(project): maven {
url "https://maven.google.com"
}
build gradle(app):implementation 'com.google.android.gms:play-services-ads:15.0.1'
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
in the xml:
<com.google.android.gms.ads.AdView
android:id="#+id/adView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-3940256099942544/6300978111"
app:layout_constraintEnd_toEndOf="#+id/normBtnID"
app:layout_constraintStart_toStartOf="#+id/ratingBtnID"
app:layout_constraintTop_toBottomOf="#+id/ratingBtnID" />
I have tried several codes, tried to put the adview programmatically and in the xml, for the current code I got the error adSize missing but it's there, when I add the ad programmatically it just shows a blank screen when launches the app
You need to add the following to either the activity or the Application class...
MobileAds.initialize(this, "YOUR_ADMOB_APP_ID");
Read more here:
https://developers.google.com/admob/android/quick-start
I thin you must to use firebase firstly you can follow this link to do that and adding ads
in correct way
https://firebase.google.com/docs/admob/android/quick-start
if you did that before
I think the error is from your admob account
go to Payments and confirm info there
ads will appear simply
I hope that will be help you
Could you try android:layout_width="match_parent" and android:layout_height="70dp" on Adview?
I faced same problem yesterday, hardcoded layout_height is work on my case.

How to pause and resume an Ad unit from serving Ads through Admob Network, IF POSSIBLE?

I have a Banner Ad unit which is served only through one ad source i.e. Admob Network. I was trying to have control over it to display ad or not as per my requirement, specifically to pause or enable an Ad unit similar to what one can do with House Ad campaigns but i couldn't find anything without people suggesting me to have server controlled flag on the Ad
I even found a way around it by setting location to the Ad for a different country when i don't want to show the ad: https://firebase.google.com/docs/admob/android/targeting#location
but problem is still the same,to have control i need to make a server call to set location to my country to stat displaying the ad
Is there a solution to this? or any better one will be highly appreciated.
When You dont want to show ad, make the Visibility of banner view to Gone
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="Your Id"
android:layout_centerHorizontal="true"/>
in main activity
AdView admobBannerView = (AdView) findViewById(R.id.adView);
//when ever you dont want to display ad
admobBannerView.setVisibility(View.GONE);
//when you want to display ad
admobBannerView.setVisibility(View.VISIBLE);

App stop working when trying to load AdMob ads

I have quiz app, and I want to make another quiz app that will be about something else.
I created new project in Android Studio and I copied all code from first quiz app.
Everything works fine, only when I start activity that have AdMob ads, app stops working.
In first quiz app everything works fine, ads are shown normally, but new quiz app stops working when trying to load AdMob ads.
Do you know where could be a problem?
This is what I use in xml file for AdMob ads:
<com.google.ads.AdView android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="id"
ads:adSize="SMART_BANNER"
ads:loadAdOnCreate="true"/>
Check the admob documentation and make sure you have the correct app ID set up in the admob details within your Android.manifest
You may have the ID from the previous app in there which will not work as the package name will be different.
https://developers.google.com/mobile-ads-sdk/
You can try
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:background="#drawable/back"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:onClick="go"
android:orientation="vertical"
tools:context=".MainActivity" >
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-7897489627187383/885626" />
</RelativeLayout>

Why won't my Admob Ads show up in my android application?

I have made an application for the Android Market and I tried to include an Ad in it using Admob. I have everything set up correctly, but the ad doesn't show up no matter what I do. If I check the Admob Marketplace I can see that there were a lot of requests sent and I got a good fillrate, too, but my ads simply do not show up in my program, as if they were invisible.
The AdView appears if I am in the graphical XML designer, but just won't show up when I run the program, although as I said, it sends a request. I would really appreciate it if you could help me out! :)
By the way, here is the main code of the AdView(I tried to add it using Java too, but it didn't show up either):
<com.google.ads.AdView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/ad"
ads:loadAdOnCreate="true"
ads:adSize="BANNER"
ads:adUnitId="MyIdHere">
</com.google.ads.AdView>
I found out that the padding of my layout prevented the Adview from
appearing. Removing the padding fixes the problem!
-- answer by Calin

Android/Admob: Can I set a list of testing devices in the Layout XML for the AdView?

So, I currently have an AdView in my layout like this:
<com.google.ads.AdView
android:id="#+id/ad"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adUnitId="XXXXXXXXXXXXXX"
ads:adSize="BANNER"
ads:loadAdOnCreate="false"/>
and that works just fine. However, I have to get the AdView in the source code in order to pass it a request for the Emulator and my personal phone to be TestingDevices and not receive real ads. Is there a way I can list those in the XML directly? or even force the AdView to ONLY show test ads, so that I don't have to have that chunk of code and can set the AdView to loadAdOnCreate?
Thanks.
Sure, add this to the xml:
ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID"
I found it here: https://developers.google.com/mobile-ads-sdk/docs/android/banner_xml

Categories

Resources