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

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

Related

How to test ads if AdView failed to load 3

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

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.

Android Ads are not clickable

I am trying to add my first advertisement to my android app. I followed a tutorial, and added the following code to my xml file
<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="#string/banner_ad_unit_id"
>
</com.google.android.gms.ads.AdView>
It displays the ad in my emulator as well as in my real device . In my emulator, the ads like 'Install This App' are displaying and download symbol also visible. In my emulator , the ad is visible and refreshing clearly but click is not at all enabled. No response with a click.
I googled stack overflow questions but no apt answers were there. Any help will be appreciated.
ps: I didnt try clicking in my emulator due to the admob ban issues
Check Your Layout Arrangements. May be Some other Layouts overlaps the ad container.So when you click it clicks the overlapped layout components.
Make sure the ad is active/ enabled in your admob account. As I remember it shows colour green when active.
Try creating another ad unit and add the ad again.
#arunprakashpj, Your AdView seems ok, but you need to check the parent layout to see if everything is ok.
You need to be sure this isn`t problem of the Ad itself. To prevent the admob ban issues you can set the emulator (or any device) as a Test Device, so you'll get Test banners that you may click without fear.
To see how to implement test banners, check this link (they have an example there): https://developers.google.com/mobile-ads-sdk/docs/admob/android/quick-start#enjoy_a_freshly_loaded_ad
Please, let us know the click result when you're using the test banners. (If click works in test ads, it means that the problem probably will be the Ad itself and not your code).
The way I solved such problem:
In Unity3D 4.XX in your current Assets folder open
Plugins > Android > AndroidManifest.xml
In the AndroidManifest.xml file under the
application > activity
you can find unityplayer.ForwardNativeEventsToDalvik property, which by default is false, like this:
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
so change it to true,
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="true" />
afterthat Save it and re-build.
In my case I was missing adding the ad-mob dependencies to the gradile, once done it worked fine.

Android AdMob SDK strange behaviour

I'm using the latest android admob SDK 6.3.1 and the first ad is downloaded and is shown on the device. Then after the refresh rate time is due, in my case 30 seconds, logcat shows that the ad has been downloaded and the new add is shown correctly. However after a second or less the new ad disappears leaving the space where the add should be blank.
Through trial and error I have found that if I touch the blank space where the ad should be it opens the correct 2nd ad link in the browser. So the add appears to be hidden in some way.
Also if I touch the bottom left hand corner of the blank 2nd ad, then the 2nd ad is shown correctly.
I've tried this with both relative and linear layouts and on different devices but the same thing happens. The first Ad shows correctly, after the refresh interval, the 2nd and all subsequent ads are downloaded and briefly displayed before going blank.
As well as trying different layouts I have also tried setting adview code in XML and programmatically in java source.
That fact that I briefly see the 2nd ad confirms that everything is okay admob server side so that makes me think it's the layout. But I have tried every combination can think of without success.
Ive tried setting: android:layout_width="320dp" android:layout_height="50dp" instead of "wrap_content" or "fill_parent".
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.google.ads.AdView android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="xxxxxxxxxxxxxxxx"
ads:adSize="BANNER"
ads:loadAdOnCreate="true"/>
</LinearLayout>
This is what I have now which is as per the official admob page.
Manifest
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<activity
android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
This is my third day trying to solve this, has anyone got any clues?
Do you think it could be device specific. Or API specific.
Best Answer for This Question is that :-
You can set up an Animation to slide the banner down, and when it's out of the view (setup a onAnimationComplete listener) call it's method :
Code in Activity:-
For visible:-
setVisibility(View.VISIBLE);
For:not Hide
setVisibility(View.INVISIBLE);
so it will not take up space in layout any more.
I'm pretty sure this can happen if the same adview id name is used in more than one activity xml.
android:id="#+id/adMob1"

AdMob AdView only appearing in landscape orientation

Ok, I'm officially at my wit's end here. Working on an Android app that uses AdMob. Everything is set up to the letter following their instructions, no errors, etc.
Problem is: I only see ads when the phone is in landscape orientation.
I've searched online and done every last thing I can think of to test this:
Tried it in test mode and normal mode
Removed the orientation configChanges from my main activity's manifest and their handlers in the code, in case they were causing it
Removed all functionality of the app so that onCreate looked like the one in the instructions above
Tried every possible change of main layout - placing it in different locations, removing other widgets, different layouts, etc
These are just a summary of a few hours of testing, every time the result is the same. Portrait shows no ad, landscape shows the ad (as/where expected - not stretched, but the max width issue is well known and not a problem).
Logcat shows everything to be working properly in both orientations: Requests are made, ads are returned. I can click on the ads that appear in landscape, but tapping the area they're meant to be in portrait does nothing.
It's driving me mental! Any ideas?
Edit: Okay, the problem is gone but I'm afraid I can't really call it a "fix". I remembered ads working fine in a previous but similar app. It was using a different version of the AdMob SDK - I don't know any details, but admob-sdk-android.jar is 77kb rather than 136kb.
I copied the 77kb one from the old app into the new app, along with the attrs.xml file, which necessitated changing the primaryTextColor attribute in the AdView to textColor, and that's it. Works perfectly now - and as a bonus, the ads stretch horizontally across the whole screen in landscape view as well!
I'm posting this as an edit rather than an answer since it seems more appropriate and I'd still love to know if anyone can shed some light on the issue. Was it an AdMob SDK issue?
I also encountered this issue, you should check if the parent container is padded, if it is, remove padding and all of sudden ads will appear. I don't find it very logical but it helps.
Not sure if this will help, but i had a similar issue, where in a landscape game, the ads would appear in portrait mode only. On a tab 2 i borrowed for testing from someone. Turned out there was some sort of screen lock on the device which caused it. Spent hours trying to chase the bug down.
Check this layout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context=".AddTest"
tools:ignore="MergeRootFrame" >
<com.google.android.gms.ads.AdView
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
ads:adSize="BANNER"
ads:adUnitId="#string/banner_ad_unit_id"
>
</com.google.android.gms.ads.AdView>
</RelativeLayout>
I have same problem in tools:ignore = "aaaaaaaaa" and padding

Categories

Resources