首页 文章

admob获得广告响应 . ErrorCode:0无法加载广告:0

提问于
浏览
62

我在这里听到了关于这个错误的许多答案,但我的问题没有解决 . 每次我运行我的应用程序时都没有广告出现,我在Logcat中收到此错误消息:

“获取广告响应时出现问题 . 错误代码:0无法加载广告:0”

这是我的java代码 . 我错过了什么?

private void LoadAds() {

 AdView mAdView = (AdView) findViewById(R.id.linearLayoutAdmob);

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

 mAdView.loadAd(adRequest);

在这里我的xml布局与最后一行的admob

<LinearLayout 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"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:orientation="vertical"
 android:background="@drawable/background_play"
 tools:context=".MainActivity" >

<RelativeLayout
    android:id="@+id/rlayout1"
    android:layout_width="fill_parent"
    android:layout_height="0px" 
    android:padding="5dip"       
    android:layout_weight="2.3" >

    <com.aapps.find.TouchImage
        android:id="@+id/gameimage1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:scaleType="fitXY"
        android:src="@drawable/ic_launcher" />

    <ImageView
        android:id="@+id/hitimage1"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:src="@drawable/hit"
        android:visibility="invisible" />

    <ImageView
        android:id="@+id/errorimage1"
        android:layout_width="30dp"
        android:layout_height="30dp"
        android:src="@drawable/miss1"
        android:visibility="invisible" />
</RelativeLayout>
<RelativeLayout
    android:id="@+id/rlayoutprogress"
    android:layout_width="fill_parent"
    android:layout_height="0px"
    android:layout_weight="0.1" >
   <com.aapps.find.utility.SaundProgressBar
    android:id="@+id/progressBar"
    style="@style/Widget.ProgressBar.RegularProgressBar"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"/>
   </RelativeLayout>
   <RelativeLayout
    android:id="@+id/rlayout2"
    android:padding="5dip"  
    android:layout_width="fill_parent"
    android:layout_height="0px"
    android:layout_weight="2.3" >
   <com.aapps.find.TouchImage
        android:id="@+id/gameimage2"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:scaleType="fitXY"
        android:src="@drawable/ic_launcher" />

    <ImageView
        android:id="@+id/hitimage2"
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:src="@drawable/hit"
        android:visibility="invisible" />

    <ImageView
        android:id="@+id/errorimage2"
        android:layout_width="30dp"
        android:layout_height="30dp"
        android:src="@drawable/miss1"
        android:visibility="invisible" />
</RelativeLayout>
<RelativeLayout
    android:id="@+id/rlstatus"
    android:layout_width="fill_parent"
    android:layout_height="0px"
    android:layout_weight="0.3" >
    <TextView
        android:id="@+id/scoreCount"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_marginLeft="15dp"
        android:textSize="16sp"
        android:textStyle="bold"
        android:textColor="#fffd7a"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true"
        android:layout_alignParentLeft="true"/>

    <TextView
        android:id="@+id/hitCount"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:textSize="16sp"
        android:textStyle="bold"
        android:textColor="#fffd7a"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true"
        android:layout_marginLeft="15dp"
        android:layout_toRightOf="@id/scoreCount"/>

    <ImageView
        android:id="@+id/imgSound"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_alignParentRight="true"
        android:layout_marginRight="15dp"
        android:src="@drawable/sound" />
    <ImageView
        android:id="@+id/imgHint"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_marginRight="15dp"
        android:layout_toLeftOf="@id/imgSound"
        android:src="@drawable/hint" />
    <TextView
        android:id="@+id/hintCount"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_marginRight="26dp"
        android:textSize="16sp"
        android:textStyle="bold"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true"
        android:layout_toLeftOf="@id/imgSound"/>
</RelativeLayout>


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

我无法弄清问题是什么 . 我是android开发的新手 .

18 回答

  • 76

    确保已在AndroidManifest.xml文件中添加此内容

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

    我在真实设备上安装应用程序后发现了模拟器的错误,广告显示完全感谢大家,我希望我的回答对其他人有用..

  • 14

    如果您的广告单元ID字符串是这样的:xyz您应该删除可翻译部分 . 对我来说,它解决了这个问题 .

  • 3

    One more reason can be: 缺少付款信息

    由于您的付款信息缺失,因此您的广告单元未投放广告 . 立即添加您的付款信息 . Learn More

  • 0

    您最有可能最近创建了一个新的广告单元ID,但您也可能因为传递 a wrong Ad Unit ID 而收到此错误 .

  • 0

    确保您的广告不违反Google广告规则,否则您必须首先填写申诉表单以联系AdMob支持,并且在重新启用广告投放后,广告应该会显示 .

  • 0

    亲爱的朋友,如果在那之后您开始使用真正的ADMOB应用程序ID而不是测试ID,只需等待几个小时(对我来说需要大约2-3个小时),之后您将获得实时的admob广告 .

  • 4

    您必须验证所创建广告的尺寸,如果广告尺寸较小,则始终会收到此错误 . 只需验证并更改为特定大小:

    ads:adSize="360x100"
    
  • 3

    打开你的adMob帐户并创建新的密钥组,并将这些密钥( Banner /插页式广告)放在你的项目中 . 这一切都发生在我这样修好后,尝试这个解决方案 . 或者仍然在adMob中创建新应用(只需更改名称)并创建新密钥

  • 5

    确保您的设备上没有安装添加阻止程序 .

  • 2

    我收到此错误是因为admob阻止了我的应用以投放广告 . 所以我 changed the package name 一切都开始完美了

  • 2

    我在测试环境中添加了以下代码

    AdRequest adRequest = new AdRequest.Builder().addTestDevice(your device id)
     //When you testing on emulator
    .addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build();
    
  • 1

    尝试使用 ads:adSize="SMART_BANNER" 更改 ads:adSize="BANNER"

  • 9

    这就是谷歌所说的

    “可能您最近刚刚创建了一个新的广告单元ID并要求提供实时广告 . 如果是这种情况,广告可能需要几个小时才能开始投放 . 如果您收到测试广告,那么您的实施就是好的 . 只需等待几个小时,看看你是否能够收到实时广告 . 如果没有,可以发送给我们你的广告单元ID供我们查看 . “

    所以基本上你要等几个小时:)

    https://groups.google.com/forum/#!category-topic/google-admob-ads-sdk/android/fBe3YL3ffpo

  • 1

    如果您在开发模式应用程序中使用实时admob广告ID,则会显示此错误 .

    在开发期间使用调试模式admob ads id,在发布模式app中使用live admob id

  • 4

    如果您刚刚开设了您的admob帐户,请先填写付款详细信息,否则即使在测试模式下也不会获得广告展示 .

  • 0

    解:

    • 如果您的帐户是新帐户,那可能就是问题所在 . 等待2-3个小时,之后它会自动开始显示广告 .

    • 如果仍然没有显示广告,可能您忘记设置付款方式 .

    如何在AdMob中设置付款方式:

    • 登录AdMob

    • 导航到屏幕左侧的"Payments"选项卡

    • 输入您的真实地址,姓名和帐户类型

    • 将广告(广告单元)放入应用程序

    • 等待2-3个小时

    • 你去!

    如果您仍然遇到问题,请随时通过电子邮件与我联系:ashkaushik0007@gmail.com

  • 11

    如果您刚刚实施了广告并且只是 want to test ,但仍然没有看到广告,请使用此 test ads ids Sample Ads Ids

    还有一件事,如果你在模拟器中测试它,那么在Kotlin中使用它

    val adRequest = AdRequest.Builder()
                    .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
                    .build()
    

    也通过this

相关问题