Question

AdMob won't show in my app. Every time I invoke loadAd(..) I get the following errors:

Requesting resource 0x7f0b000e failed because it is complex. The Google Play services resources were not found. Check your project configuration to ensure that the resources are included. There was a problem getting an ad response. ErrorCode: 1

I searched hours for a solution to this problem but haven't found anything that works for me! I downloaded the latest version of the Google Play Services and added them as library in my project preferences

Here is my code: Activity:

public class WelcomeActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.setContentView(R.layout.activity_welcome);

        // Look up the AdView as a resource and load a request.
        AdView adView = (AdView) this.findViewById(R.id.welcomeAdView);

        AdRequest.Builder adRequestBuilder = new AdRequest.Builder();
        adRequestBuilder.addTestDevice("************"); 
        adRequestBuilder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);
        AdRequest adRequest = adRequestBuilder.build();
        adView.loadAd(adRequest);
    }

}

Layout xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res/xx.xx"
    android:id="@+id/container"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    tools:context="xx.xx.WelcomeActivity" >

.... other layout stuff .....

<RelativeLayout
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_alignParentBottom="true" >

    <com.google.android.gms.ads.AdView
        android:id="@+id/welcomeAdView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        ads:adSize="BANNER"
        ads:adUnitId="pub-***************" />
</RelativeLayout>

</RelativeLayout>

AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="xx.xx"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="19" />

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Holo.Light" >
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

        <activity
            android:name="xx.xx.WelcomeActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        ... some more activities ...
        <activity
            android:name="com.google.android.gms.ads.AdActivity"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" >
        </activity>
    </application>

</manifest>
Was it helpful?

Solution

I don't find any issue with your code/layout. Issue could be with the Ads Unit Id.

I would suggest you to try creating a different Ads Unit Id

Hope it works.

OTHER TIPS

Just adding this in case someone else has the same problem as mine.

I tried using a new Ads Unit ID and that didn't work as well. In the end, the issue was because I was trying to fix an app that got suspended from Google Play and Admob had also actually stopped serving ads to applications with the specific package name / bundle ID.

Changing the package name of the application solved the issue for me.

Be careful of the ad-unit id string. My error was a space in the end of the adUnitId

In your layout file (activity_welcome.xml), the adview container (RelativeLayout) layout width/height looks strange to me. And I think it is useless in your use case.
Change from:

<RelativeLayout
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_alignParentBottom="true" >

    <com.google.android.gms.ads.AdView
        android:id="@+id/welcomeAdView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        ads:adSize="BANNER"
        ads:adUnitId="pub-***************" />
</RelativeLayout>

to:

<com.google.android.gms.ads.AdView
    android:id="@+id/welcomeAdView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    ads:adSize="BANNER"
    ads:adUnitId="pub-***************" />

You used wrong ads:adUnitId="pub-***************". It must looks like ca-app-pub-3940256099942544/6300978111 format. You can take it after creating banner by url https://apps.admob.com/#monetize/adunit:create

Add this inside application tag in your Manifest file:

<meta-data android:name="com.google.android.gms.version"
     android:value="@integer/google_play_services_version"/>

Also Your package might be blocked by Google AdMob. If you received a email like this:

Hello,

This email is to alert you that one of your applications is not currently in compliance with our AdMob program policies and as a result, ad serving has been disabled to your application.

Ad serving has been disabled to: APPNAME (com.example.pack)

Action required: Check all other remaining applications in your account for compliance.

Current account status: Active .....

So now you need to change your package of your app. on eclipse it is package="com.example"

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