Google ads in android app - android

I am working with adding Google ads in android apps...
my code is as follows
adView = new AdView(this, AdSize.SMART_BANNER, "xxxxxxxxxx");
LinearLayout layout = (LinearLayout)findViewById(R.id.mainlayout);
layout.addView(adView);
AdRequest ads=new AdRequest();
ads.addTestDevice(AdRequest.TEST_EMULATOR);
adView.loadAd(ads);
all is working fine on emulator but doesn't show ads on my device
please suggest me what i'm doing wrong here

Using AdRequest.addTestDevice(TEST_EMULATOR) is the way to fetch the add during testing. However, this piece of code will only fetch test ads from emulators. Everyone running your app on a device will get live ads, and you'll get revenue when users click on those live ads.
Even if you used AdRequest.addTestDevice("YOUR_DEVICE_ID") to get test ads on your device, this only requests test ads on that one specific device, and every other device will get live ads. You don't have to worry about your users getting test ads once you release.
To get DEVICE_ID check this.
This is said by Eric Leichtenschlag Developer Programs Engineer for Google, specializing in Google AdMob Ads SDK support.
You need to check this.

Related

is admob banner show before publish application?

I add all codes of admob into my project and when I test it by admob test code , it work well . but
if i try to add my own appID and UnitID , my Ads don't shows
//
I think before publishing App it doesnt show
am I right or I have some other problem ?
java.class
layout.xml
Manifest.xml
I don't think that I have code problem
I think it is because of that my app in not published
please answer me thank you.
This will surely shows the advertisement even without publishing app. Make sure you also sign in to google adsense with the same account you signed in to admob.
Make Sure your payment account is setup with admob.
Also for testing purpose, you need to add your device as text device.
Like This
smartAd = (AdView) findViewById(R.id.smartAd);
adRequest = new AdRequest.Builder().addTestDevice("709D9B***********629841A46A05C6B").build();
smartAd.loadAd(adRequest);
You can find your device number in logs.
Hope this will help.

admob is working on test id but not with live id

I have added admob banner ad code on my app, it is working fine in test env with test id but as soon as I publish it on playstore with LIVE id it stops working, I am using following code.
MobileAds.initialize(this, "ca-app-pub-***********");
mAdView = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
<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"
ads:adSize="BANNER"
ads:adUnitId="#string/adUnitId"></com.google.android.gms.ads.AdView>
According to Google Admob, if test ad is working the live ad will also work because they got generated from same channel. In live ad situation it can take time up to 1-4 days to start, so just wait for it.
Check your mail, just to be sure you haven't violated any AdMob rules or whatevs. They could disable serving ads to an app or your account. Sometime they did that to mine i took 4 days to notice.
It works don't take tension. If your Admob account is new then it may take time up to one month to start showing live Ads.
You may also verify if you have provided the right billing address in your AdMob account, if you have then you should see the given message
Congratulation we have verified your Account.
A month back when I created a new AdMob account, the ads were not showing up so do verify your billing address as mentioned.
In your case, live Ads Are not showing, my live Ads were showing as soon as I generated a signed APK from Android Studio without the app being published on play store.

How to add text converting button in android studio

I had placed adMob ads in my android application. Now I'm watching an Ad unit on which the following line is written.
Congratulations! You are displaying an adMob Ad
There is no real ad appearing. Anyone tell me is this ok or not?? will I get money for these ads or not?
You will not get paid showing test Ads. AdMob shows test Ads if you are using an emulator or if you have added your device as a test device. It also shows test Ads if you are using the test Ad Unit ID it provides in document.
Check your code to see if your have enabled test Ads:
AdRequest request = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR) // All emulators
.addTestDevice("AC98C820A50B4AD8A2106EDE96FB87D4") // An example device ID
.build();

AdMob ban risk, anyone with specific info?

One year ago my admob account had been banned for a month as I allowed beta testers to click on my banners, resulting in a lot of clicks and causing my 30 day ban from admob.
I'm working on a game and forgot to set my banner in test mode, so i started the game in my device, interstitial was loaded and generated money (0.19$) in my admob account, of course i fixed the problem immediately but I learnt that theres a risk of permanent ban for users who have already been warned.
I can't lose my admob account just because of one click.Any suggestions?Thank you.
There's an option for you to request the admob team to not disable your account. Visit https://support.google.com/admob/faq/3364907#3365454 and go through "Can I appeal the disabling of my account?" and fill the appeal form
If you have list of all devices, please add them as TestDevices so that you will never recive real advertisments on those phone. Please refer admob sample code given to get device ID.
// Create an ad request. Check logcat output for the hashed device ID to
// get test ads on a physical device.
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("INSERT_YOUR_HASHED_DEVICE_ID_HERE")
.build();

What does adRequest.addTestDevice("device_id") mean?

I'm confused about admob adrequest.
I don't understand adRequest.addTestDevice("device_id").
If I write:
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice(DeviceInfo.getDeviceId(activity)).build();
for every single device, will it affect my AdMob account?
Or is addTestDevice("deviceid") only for each testing device or real life device?
If I add only my test device's id to AdRequest then will it display the ad to other devices or not?
According to the docs:
It's important to make sure you always request test ads when developing and testing your applications. Testing with live, production ads is a violation of AdMob policy and can lead to suspension of your account. For more information on how to use test ads, see our Ad Targeting guide.
This means your account won't be affected when utilizing test ads regardless of the number of devices/emulators you use.
Basically addTestDevice("deviceid") prevents generating false impressions and ensures test ads being available always.
You can remove all calls to addTestDevice("deviceid") when you're done testing and transitioning to the production phase.
AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).addTestDevice("1915F1CFC0D22C6DBB4C8ED97B0CCBA1").build();
This is how you have to add your device id, you can get your device id from your logs in Android studio.
and only for that device, test ads will be loaded.
As per Google policy if you want to test ads then you need to define testing device id in your app or if you are not defining the testing device and test that app a lot of time in one device then Google will consider it as an illegal activity for ad revenue, So we need to define test device id in our debug apps.
Note: Do not click on ads even if you've added device ID in your app. That will be considered as a policy violation and your account may be blocked. You can only test the ads are visible in your app or not.
As mentioned by #AnkitaKoladiya's answer you can use this:
AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build();
You can use it like below to avoid accidentally creating a signed APK with testing device ID:
AdRequest.Builder builder = new AdRequest.Builder();
if (BuildConfig.DEBUG) {
builder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);
}
builder.build();
This will not include builder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR); while building a signed APK. But it will include this in Dubug or test APK file. All device which installs APK with this line (builder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);) will be considered as a testing device. So you need to remove that when you'll making a signed APK for Playstore.
And if you don't find your device id, then first run your app without testing device ID in your testing device. After a successful build, you will see your device ID in Logcat.

Categories

Resources