getting an ad response. ErrorCode: 1
Asked Answered
G

5

8

I am testing my application in device it is showing the error in debug logcat what is this error and how to solve this?

The error is

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

my xml code is

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
     xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/accent_material_light"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"

     >
      <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_alignParentBottom="true"
        ads:adSize="BANNER"
        ads:adUnitId="@string/banner_ad_unit_id">
    </com.google.android.gms.ads.AdView>

my code to display the ads is

AdView mAdView = (AdView) findViewById(R.id.adView);
            AdRequest adRequest = new AdRequest.Builder().build();
            mAdView.loadAd(adRequest);

and in manifest file I am adding.the code is working fine but the ads are not displaying I am testing it on my device

<application
        android:allowBackup="true"
        android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
         <!--This meta-data tag is required to use Google Play Services.-->
        <meta-data android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
<activity android:name="com.google.android.gms.ads.AdActivity"
                android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
                android:theme="@android:style/Theme.Translucent" />
Georgiannageorgianne answered 28/10, 2015 at 6:37 Comment(0)
V
27

Try to use Ad unit ID.

You may mistakenly use the APP ID or PUBLISHER ID.. (Like my mistake)

Sample Ad Unit ID (it contains xxxxx/xxxxx)

ca-app-pub-9390048287444061/3221111032 - correct one

Sample App ID (it contains xxxxx~xxxxx)

ca-app-pub-9390048287444061~1222077830 - wrong one

Verrucose answered 11/1, 2017 at 6:17 Comment(1)
I cant imagine how stupid I was to use App ID instead of Ad Unit ID and searching every other solution why ads were not being shown. Thanks ManBaptize
G
2

the issue is solved by adding the ad-Unit Id Other than publisher id and adding the test device id through AdRequest

Georgiannageorgianne answered 28/10, 2015 at 7:35 Comment(0)
D
1

as you say, you have done all attempt write all code perfectly in manifest as well as build.gradle file. this same problem was to me.

so after that i have resolved this problem by correcting my ad-mob unit id and also it was written in uppercase.so i modify it to lowercase and works perfectly.

This works for me.Hope this help others too!!.

Dinghy answered 18/7, 2016 at 3:31 Comment(0)
T
0

I had the same problem.

I believe Error Code 1 is due to many different reasons, but mine was wrong adSize. I set up for NativeAdExpress, but was giving wrong dimensions in XML, MEDIUM_RECTANGLE worked for my NativeAdExpress view.

Tuppence answered 19/8, 2017 at 11:41 Comment(0)
S
-3

try adding below code to you gradle file.

compile 'com.google.android.gms:play-services-ads:8.1.0'
Semele answered 28/10, 2015 at 7:28 Comment(1)
You didn't explained the line that you have added and it is not related answer in anyway.Saguaro

© 2022 - 2024 — McMap. All rights reserved.