How to implement Admob AdView in an Android application

I want to use Admob in my application. I downloaded the SDK and followed the steps. Sometimes I get an ad in return, but most of the time I get an entry in LogCat that says: β€œThe server did not find ads” or something like that. Test mode is on, says the Admob website. I think I can do something wrong. Where can I get a step-by-step guide on how to place admob ads in Android apps? Admob developer site is not enough.

Also, suppose everything went well and that I would now like to deploy the application. How to disable test mode Admob ads?

Thanks.

+7
android admob logcat
source share
5 answers

just follow the instructions on this site: http://developer.admob.com/wiki/Android#AdMob_Android_SDK

I think you did not activate the test mode for your device or emulator ?!

AdManager.setTestDevices( new String[] { AdManager.TEST_EMULATOR, // Android emulator "E83D20734F72FB3108F104ABC0FFC738", // My T-Mobile G1 Test Phone } ); 
+4
source share

Download the AdMob jar file http://www.admob.com/my_sites/

Create a package in your project and name it "libs" and paste this AdMob.jar file there

Right-click on your project, select the library, add the path for the just saved ADMOB.jar there.

If you create your AdView on your XML, you can add this line

This is an example of testing. When you get your own ID from ADMob, put it on adUnitID and erase the test line.

  com.google.ads.AdView android:id="@+id/adView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" ads:adSize="BANNER" ads:adUnitId="a14f59e5c442767" ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID" ads:loadAdOnCreate="true" </com.google.ads.AdView> 

Now go to your .java so that it invokes this layout and creates an AdView

 AdView adView = (AdView)this.findViewById(R.id.adView1); adView.loadAd(new AdRequest()); 

This is how I do it, and it still works.

Sorry for the bad english, a lot of code and no sleep!

+8
source share

It seems like it could change to

 AdRequest request = new AdRequest(); request.addTestDevice(AdRequest.TEST_EMULATOR); request.addTestDevice("E83D20734F72FB3108F104ABC0FFC738"); // My T-Mobile G1 test phone 

see http://code.google.com/mobile/ads/docs/android/intermediate.html

According to Tom's comment below, the value for adding addTestDevice is actually an MD5 hash of the device identifier. You can get this from the logarithm.

+3
source share

Just add permission on Android mainfest:

 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 

Check it once.

Then add this code:

 AdManager.setTestDevices( new String[] { AdManager.TEST_EMULATOR, // Android emulator "E83D20734F72FB3108F104ABC0FFC738", // My T-Mobile G1 Test Phone } ); 
+1
source share

You do not need to call it programmatically.

It took me a while until I found out which device is AdMob sdk, which was expected because I thought it was connected to a real device like (adb devices)

But here is a comment from the official documentation that cleaned it up.

There will be a log message with the code necessary to add the current device to the list of test devices

You may receive a message similar to it

 I/Ads(26674): To get test ads on this device, call adRequest.addTestDevice("F1254CDFBA84BDC27F5C7C6E12445D06"); 

All you have to do is put this id in your xml layout below

 <com.google.ads.AdView android:layout_alignParentBottom="true" android:id="@+id/adView" android:layout_width="match_parent" android:layout_height="wrap_content" ads:adSize="BANNER" ads:adUnitId="@string/publisherId" ads:loadAdOnCreate="true" ads:testDevices="TEST_EMULATOR, F1254CDFBA84BDC27F5C7C6E12445D06" /> 

Hope it helps you guys

Paulo Miguel Almeida

+1
source share

All Articles