I just added AdMob to my Android app DRoute and it doesn’t work. I receive many calls to onFailedToReceiveAd event function

  1. @Override
  2.         public void onFailedToReceiveAd(AdView adView)
  3.         {
  4.                 Log.d("DRoute", "onFailedToReceiveAd");
  5.                 super.onFailedToReceiveAd(adView);
  6.         }

I dig into the problem, search on the internet and didn’t found a solution. This morning I’ve created step by step a fresh new app only to test AdMob publisher code and ID and it works fine on emulator with :

  1. AdManager.setTestDevices(new String[] {AdManager.TEST_EMULATOR});

After step by step testing I found out that the problem was with a padding value that I have in my surrounding

Before (not working ) :

  1. <ScrollView  xmlns:android="http://schemas.android.com/apk/res/android"
  2. xmlns:myapp="http://schemas.android.com/apk/res/com.android.example.testad"
  3. android:id="@+id/scrllvwNo2"
  4. android:layout_width="fill_parent"
  5. android:layout_height="fill_parent"
  6. android:fillViewport="true"
  7. android:background="#ffffff">
  8. <RelativeLayout
  9.     android:layout_width="fill_parent"
  10.     android:layout_height="fill_parent"
  11.     android:background="#ffffff"
  12.     android:padding="10dip">
  13. <!– app layout –>
  14. <com.admob.android.ads.AdView
  15.                         android:id="@+id/ad"
  16.                         android:layout_width="fill_parent"
  17.                         android:layout_height="wrap_content"
  18.                         android:layout_alignParentBottom="true"
  19.                         myapp:backgroundColor="#FFFFFF"
  20.                         myapp:primaryTextColor="#000000"
  21.                         myapp:secondaryTextColor="#CCCCCC"/>
  22. </RelativeLayout>
  23. </ScrollView>
  24.  

After ( the solution ) :

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <ScrollView  xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:myapp="http://schemas.android.com/apk/res/com.devicefms.android.droute"
  4. android:id="@+id/scrllvwNo2"
  5. android:layout_width="fill_parent"
  6. android:layout_height="fill_parent"
  7. android:fillViewport="true"
  8. android:background="#ffffff">
  9. <LinearLayout android:layout_width="fill_parent"
  10.     android:layout_height="fill_parent"
  11.     android:orientation="vertical">
  12. <RelativeLayout
  13.     android:layout_width="fill_parent"
  14.     android:layout_height="wrap_content"
  15.     android:background="#ffffff">
  16.     <!– app layout –>
  17. </RelativeLayout>
  18. <com.admob.android.ads.AdView
  19.                         android:id="@+id/ad"
  20.                         android:layout_width="fill_parent"
  21.                         android:layout_height="wrap_content"
  22.                         myapp:backgroundColor="#FFFFFF"
  23.                         myapp:primaryTextColor="#000000"
  24.                         myapp:secondaryTextColor="#CCCCCC"
  25.                         />
  26. </LinearLayout>
  27. </ScrollView>