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"
Related
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.
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
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
I've got a problem with Admob not showing up Ads...
Here's the LogCat:
WARN/AdMobSDK(502): Ignoring requestFreshAd() because we are requesting an ad right now already.
INFO/AdMobSDK(502): No fill. Server replied that no ads are available (1164ms)
INFO/AdMobSDK(502): No fill. Server replied that no ads are available (846ms)
I've tried test mode, no test mode, emulator, real phone, etc. It never shows anything up, but I get requests and prints on Admob stats, like if it ever worked...
AFAIK, I did everything in the Admob Android SDK... the only thing that could be the cause of any problems, IMHO, would be the fact that I'm using tabbed layout with scrollview and then a relativelayout where the ad shows...
Here's a sample of the layout for a tab:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res/com.xxx.xxx"
android:id="#+id/tababout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FF000000">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FF000000"
android:padding="10px">
<ImageView
android:id="#+id/label_img"
android:src="#drawable/about_header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="centerInside" />
<TextView android:id="#+id/label_know_more_desc"
style="#style/Desc"
android:layout_below="#id/label_img"
android:text="#string/tab_about_know_more_desc" />
<Button android:id="#+id/bt_know_more"
style="#style/Button"
android:gravity="center_vertical|center_horizontal"
android:layout_below="#id/label_know_more_desc"
android:text="#string/tab_about_know_more_bt" />
<com.admob.android.ads.AdView android:id="#+id/ad" android:layout_width="fill_parent" android:layout_height="wrap_content" myapp:backgroundColor="#000000" myapp:primaryTextColor="#FFFFFF" myapp:secondaryTextColor="#CCCCCC" />
</RelativeLayout>
</ScrollView>
And here's the main.xml, not that I think you need it:
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/tabhost"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FF000000">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabWidget
android:id="#android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FF000000"
android:paddingTop="5px">
</FrameLayout>
</LinearLayout>
</TabHost>
I've read in Admob ads will not display when placed inside a tabview that the problem could be the 10px padding I'm throwing in, but even if I disable that, it doesn't work.
I even tried moving the xmlns:myapp to RelativeLayout, but obviously didn't change anything....
Also, I've made my first live ad request over 24 hours ago...
EDIT
Ok, now I'm getting somewhere, I've managed to get test ads showing up (my setTestDevices was too late in the onCreate code, I pushed it up to the first lines), but not real ones... am I missing something? I obviously commented out the setTestDevices line and no ads show up
EDIT 2
Well, I added two internal ads (I already had internal ads enabled, but no internal ads set), and suddenly ads started showing on my app (not only internal ads).
I guess everything altogether made it work?! :)
Thanks everyone!
You aren't positioning the ad's in the RelativeLayout (they need a layout_above or layout_below or whatever to specify where to put them).
Also there is a minimum size for admob that you might want to ensure you match, I think it's like 48dip in height at least, not sure what the horizontal is.
Lastly I don't know where you are trying to place your ad's, but it probably would make more sense in your main frame-layout, I have a padding at the bottom of my app which I use for the ad-view.
Edit: also if your app is public check for ad-revenue. Android pre 2.3 allowed ad's to be hidden behind views and still register clicks. I actually made my initial $1 before my ad's were even visible by anyone.
Another reason that the AdMob Ads won't show up is that you haven't declared the AdActivity which will display the ads when they are clicked on. Without the AdActivity declared in my AndroidManifest.xml, I don't see the ads. With it declared, the Ads show up.
...AndroidManifest.xml...
<!-- AdMob -->
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation"/>
The first time i focus an edittext view i notice a lag of one or two seconds before i can write anything in the textbox.
I notice this behavior even on an app without any code more than what's nessecary to initialize the application.
What am i doing wrong?
I've INSTANTLY fixed this issue for me; I saw in the DDMS that a lot of redraw's and recalculations were occurring while entering text, and a lot of info about RelativeLayouts were being called. So, I checked my layout; i had some Multi-Line EditText's who were direct children of a RelativeLayout. So, I wrapped those up into a Linear Layout, and specified my desired width/height at the LinearLayout, not each EditText.
Guess what? It totally fixed it!!
(below, some code... keep in mind, this is just an approximation. Don't try and copy/paste)
BEFORE:
<RelativeLayout>
<EditText
android:layout_width="wrap_content" />
<EditText
android:layout_width="wrap_content" />
</RelativeLayout>
AFTER:
<RelativeLayout>
<LinearLayout
android:layout_width="wrap_content" >
<EditText
android:layout_width="fill_parent" />
<EditText
android:layout_width="fill_parent" />
</LinearLayout>
</RelativeLayout>
Wrapped my EditText's into a LinearLayout, and relinquished dynamic layout controls to the LinearLayout.
It was an amazing and instant improvement.
Are you using the emulator?
This is common when you are using the emulator regardless of debug mode or not...at least from my (limited) experience so far. Try your app out on a real phone and see what happens.
I turned off USB debugging and uninstalled a few keyboards. Seems to work fine now. Thanks all.
Edit AndroidManifest:
My old code
< uses-sdk android:minSdkVersion="8" android:targetSdkVersion="21" />
My new code
< uses-sdk android:minSdkVersion="8" />
I just removed the targetSdkVersion and the lag went away.
In my case the symptoms were the same, a delay occurred to present the keyboard and when typing the letters were gradually appearing.
The solution is because I had put a Background image in the RelativeLayout, when I did a test taking the background worked out and stopped the delay, so I entered an online site that reduces photos and then reduced from 93kb to 50kb and worked perfectly.
In my case the problem was the background-drawable for the activity (as dialog) on XML, it was too heavy. changing it, works fine.
In my case, the lag was because of the heavy serialised objects I used to pass in Intent putExtra() of activities in the app. Those would continue to stay in the memory and cause the problem.