Failed to load ad (Error 1)
Asked Answered
A

5

8

Have been searching for hours on google, but still without success. I always get the Error Message and the adBanner doesnt load:

There was a problem getting an ad response. ErrorCode: 1
Failed to load ad: 1

build.gradle

compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.google.android.gms:play-services-ads:9.4.0'

Android Manifest

<activity
        android:name="com.google.android.gms.ads.AdActivity"
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
        android:theme="@android:style/Theme.Translucent"
        />

layout

<com.google.android.gms.ads.AdView
    android:id="@+id/adView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    ads:adSize="BANNER"
    android:layout_marginTop="20dip"
    ads:adUnitId="pub-*****************"
    android:layout_below="@+id/middle"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true" />

activity (imports)

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;

activity

AdView adView = (AdView)findViewById(R.id.adView);

    AdRequest adRequest = new AdRequest.Builder().build();
    adView.loadAd(adRequest);

permissions are also added

ty for your help in advance

Amaro answered 8/8, 2016 at 18:4 Comment(3)
Double check your add unit ID: I think it should look like ca-app-pub-....Fairman
yeah i have also tried this one ca-app -pub...., but didnt work neither :/Amaro
Just checking if you have initialised the Google Mobile Ads SDK as follows: MobileAds.initialize(getApplicationContext(), getString(R.string.admobs_app_id)); Hummock
F
10

I got this error on Adaptive banner for android

I/Ads: Ad failed to load : 1

because of this line

width = (int)( metrics.widthPixels);

Solution

DisplayMetrics metrics = new DisplayMetrics();

getWindowManager().getDefaultDisplay().getMetrics(metrics);

width = (int)( metrics.widthPixels/metrics.density);

AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(mContext, width);

I hope it helps someone.

Forepeak answered 12/3, 2020 at 7:53 Comment(1)
Thanks. I assumed the width passed should be the width in pixels, but it's not. It's widthPixels / density.Multiflorous
W
9

Error 1 means the ID is wrong.

Admob gives you a number like this and is the general ID, with ~ :

ca-app-pub-9611919736642270~3440171884

And the ads id with / is to the request;

ca-app-pub-9611919736642270/3440171834
Words answered 14/11, 2017 at 21:8 Comment(1)
can you explain clearly? I have adUnitId with ~ I can not load add in both debug and release build. How do I fix this.Nydia
L
1

The error code 1 refers to Invalid request.

//(public static final int ERROR_CODE_INVALID_REQUEST The ad request was invalid; for instance, the ad unit ID was incorrect. Constant Value: 1) //

Thus you must check whether your Ad-Ids are defined at right place. Don't put banner ads id to interestial ads and vice versa. for other error codes just take a look on this link: https://developers.google.com/android/reference/com/google/android/gms/ads/AdRequest#ERROR_CODE_NO_FILL

Lissa answered 26/7, 2017 at 9:32 Comment(0)
B
0

Add the following meta data to AndroidManifest.xml file:

<meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
Breeding answered 16/9, 2017 at 9:4 Comment(0)
L
0

Some ad sizes don't seem to work when trying to load ads. I tried LEADERBOARD and it looked good in the android preview. But the ads didn't load. I changed it to BANNER and it works now.

        <com.google.android.gms.ads.AdView
        android:id="@+id/ad_view"
        android:background="@color/white"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        **app:adSize="LEADERBOARD" <<<<<<<<**
        app:adUnitId="ca-app-pub-3940256099942544/6300978111">
Lysias answered 13/6 at 21:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.