Question

I want to use Admob in my app. I've 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 "Server did not find any ads" or something to that effect. Test mode is enabled, says the Admob site. I think I might be doing something wrong. Where can I get a step-by-step guide to insert admob ads in Android apps? The Admob developer site is rather lacking.

Also, let's assume that everything's gone well and that I'd now like to deploy the app. How do I turn off test mode for Admob ads?

Thank you.

Was it helpful?

Solution

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

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

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

OTHER TIPS

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

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

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

If you're creating your AdView on your XML, you can add this line.

This is an example for testing. When you get your own ID from ADMob, place it on the 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 that it calling this layout and create your AdView

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

This is how I do and its been working good so far.

Sorry about bad english, to much code and no sleep!

It seems as though this might have changed 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

As per Tom's comment below the value to provide for addTestDevice is actually the MD5 hash of the device ID. YOu can get this from the logcat.

Just add a permission to the 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
} );  

You don't need to call it programmatically.

It took me a while until I get what device is AdMob's sdk what expecting cuz' I was thinking it was something related to the real device like ( adb devices )

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

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

You may get an message similar to it

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

All you have to do after that is to place this ID into your layout xml as 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 out

Paulo Miguel Almeida

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top