获得广告响应.错误代码:1

getting an ad response. ErrorCode: 1(获得广告响应.错误代码:1)
本文介绍了获得广告响应.错误代码:1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设备中测试我的应用程序,它在调试 logcat 中显示错误这个错误是什么以及如何解决这个问题?

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

错误是

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

我的xml代码是

<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>

我展示广告的代码是

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" />

推荐答案

尝试使用广告单元 ID.

Try to use Ad unit ID.

你可能误用了APP ID或PUBLISHER ID..(和我一样)

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

示例广告单元 ID(它包含 xxxxx/xxxxx)

Sample Ad Unit ID (it contains xxxxx/xxxxx)

ca-app-pub-9390048287444061/3221111032 - 正确一个

示例应用 ID(包含 xxxxx~xxxxx)

Sample App ID (it contains xxxxx~xxxxx)

ca-app-pub-9390048287444061~1222077830 - 错了一个

这篇关于获得广告响应.错误代码:1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)
Crash on Google Play Pre-Launch Report: java.lang.NoSuchMethodError(Google Play发布前崩溃报告:java.lang.NoSuchMethodError)