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

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.

Related

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();

Do I need to remove testDevice code for AdView in android before publishing?

AdView mAdView = (AdView) findViewById(R.id.adViewGame);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice("27CBA8D2XXXXXXXXXD7996125")
.build();
mAdView.loadAd(adRequest);
Do I need to remove any line from the above code before generating the signed apk for publishing?
No it's a unique id for your device, So if you tried to install this app from the PlayStore on this device you will see the test ads not the real one.
Also i published my app with the same code and no problem at all.
Just make sure you are actually requesting ads using a live/prod ad unit ID! However, I'd remove the test device ID for two reasons.
First of all, it's not really doing anything there. It's a way for the SDK to tell if a device is yours, and deliver test ads on it. However, now that your app is on the Play Store, you don't need that offer anymore.
Second, it's a unique device ID so you wouldn't want it flying about out of your hands. Security reasons.

What is the right way to use admob in my app

I just finished my first app, and plan to earn money by admob ads. When I monetise a new app on admob, it want me to search my app in app markets. Does it mean that I should publish my app before put ads in it?
If so, what should I do after getting the admob ad unit id? Copy it into my code and republish a new version of my app which contains the real ads (not the test one)? It sounds stupid to build and publish a new version of app only to put some ads in it.
You should create the Ad Units on AdMob, and then, you only add the next line when you do the requests in your code:
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("XXXXX")
Where "XXXXX" is a the code associated to that specific device, that you obtain in the Logcat. You can add as many devices as you want to test. It is not necessary to remove the lines when compiling or when releasing for Google Play.
You should compile your first release with the ad code ready to go. (That's what I always do).
You use the test script so that you get dummy ads, that their clients don't get charged for, when you're testing. Then you simply swap out that line for the REAL ad serving code when you're ready to release.
You're not going to get in any trouble if you test with the actual admob code as long as you dont:
1. Click an ad. Ever.
2. Test it a gazillion times. Use the test ad for that.

Using Admob for testing vs live

I am finishing up my first app which includes Admob. I have entered my ad unit ID and it is working perfect. I am currently on beta testing, so in order to see 'test' adds, I added my own device using the recommended method:
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice("xxxxxxxxxxxxxxxxxxxx").build();
I have 2 questions:
For Beta testing, how can I prevent my testers to see the live ads without knowing their device IDs?
For go-live, do I have to remove the addTestDevice() calls so I can see the real thing?
What is the usual procedure ?
For Beta testing, how can I prevent my testers to see the live ads
without knowing their device IDs?
You have to know their device id, otherwise they will see real ads. However, you can get device id programatically to put it in addTestDevice() method. See this link
For go-live, do I have to remove the addTestDevice() calls so I can
see the real thing?
It is not necessary to remove the addTestDevice(). But if you want to see real ads then yes it is necessary; though it is better to not remove addTestDevice(), that's how you can prevent yourself from accidentally clicking ads.

Google ads in android app

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.

Categories

Resources