简体   繁体   English

为什么我的Admob奖励视频广告一次又一次无法加载?

[英]Why my Admob Rewarded Video Ad Failed to load again and again?

I just want to display Rewarded Video Ad by using test id but it failed again and again while loading.Someone can tell me that what I am doing wrong. 我只想使用测试ID来显示“奖励视频广告”,但加载时一次又一次失败。有人可以告诉我我做错了什么。 Here is my Main Activity Kotlin. 这是我的主要活动Kotlin。

import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.widget.Toast
import com.google.android.gms.ads.AdRequest
import com.google.android.gms.ads.MobileAds
import com.google.android.gms.ads.reward.RewardItem
import com.google.android.gms.ads.reward.RewardedVideoAd
import com.google.android.gms.ads.reward.RewardedVideoAdListener

class MainActivity : AppCompatActivity (), RewardedVideoAdListener {
override fun onRewardedVideoAdClosed() {
        loadRewardedVideoAd()
}

override fun onRewardedVideoAdLeftApplication() {
    TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}

override fun onRewardedVideoAdLoaded() {
    mRewardedVideoAd.show()
}

override fun onRewardedVideoAdOpened() {
    TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}

override fun onRewardedVideoCompleted() {
    TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}

override fun onRewarded(p0: RewardItem?) {
    TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}

override fun onRewardedVideoStarted() {
    TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}

override fun onRewardedVideoAdFailedToLoad(p0: Int) {
    Toast.makeText(this,"Failed!",Toast.LENGTH_LONG).show()
}

private lateinit var mRewardedVideoAd: RewardedVideoAd

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    // Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713
    MobileAds.initialize(this, "ca-app-pub-3940256099942544~3347511713")

    // Use an activity context to get the rewarded video instance.
    mRewardedVideoAd = MobileAds.getRewardedVideoAdInstance(this)
    mRewardedVideoAd.rewardedVideoAdListener = this

    loadRewardedVideoAd()
}

private fun loadRewardedVideoAd() {
    mRewardedVideoAd.loadAd("ca-app-pub-3940256099942544/5224354917",
            AdRequest.Builder().build())
}

} }

Here is the code that I write in android manifest. 这是我在android manifest中编写的代码。

<!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
    <meta-data
        android:name="com.google.android.gms.ads.APPLICATION_ID"
        android:value="ca-app-pub-3940256099942544~3347511713"/>

Permissions. 权限。

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

Here is the line that I write in build.gradle(project: app_name). 这是我在build.gradle(project:app_name)中编写的行。

allprojects {
repositories {
    jcenter()
    maven {
        url "https://maven.google.com"
    }
}

} }

Here is the line that I write in build.gradle(Module: app). 这是我在build.gradle(Module:app)中编写的行。

    implementation 'com.google.android.gms:play-services-ads:15.0.1'

Here are some common causes and how to fix them: 以下是一些常见原因以及解决方法:

  1. Make sure you have updated AdMob with your payment details 确保您已使用付款明细更新了AdMob
  2. Make sure that the ads you created in AdMob are banner ads. 确保您在AdMob中创建的广告是横幅广告。
  3. Check your AdMob dashboard to see the status of your ads, are they active? 检查您的AdMob信息中心以查看广告状态,它们是否处于活动状态?
  4. Verify you used the correct Ad Unit Id. 确认您使用了正确的广告单元ID。
  5. Give it 24 hours, it can take time for an ad to become active in your region Also keep in mind: 给它24小时,广告可能需要一段时间才能在您所在的地区生效。另外请注意:

  6. It's too early for the ads to fill. 现在填充广告还为时过早。 English speaking regions tend to get a faster fill-rate as there are more advertisers targeting these markets. 讲英语的地区往往会获得更快的填充率,因为有越来越多的广告商瞄准这些市场。 The smaller the market, the slower the fill-rate. 市场越小,填充率就越慢。 Wait 48 hours and see if the issue resolves. 等待48小时,看看问题是否解决。

  7. Your region has a slower fill-rate. 您所在地区的填充率较低。 You notice you're making income, but when you test the game yourself you can't see any ads in your game. 您会注意到自己正在赚钱,但是当您自己测试游戏时,您在游戏中看不到任何广告。 The region you are testing from may have a slower fill-rate, but advertising is active in the other regions you released for. 您要测试的区域的填充率可能较慢,但是在您为其发布的其他区域中,广告仍然处于活动状态。 Wait 48 hours and your region should be updated with active ads. 请等待48个小时,您所在的区域应使用有效广告进行更新。

  8. You haven't entered your payment details. 您尚未输入付款明细。 We have received reports from users, particularly using AdMob, that their banners haven't filled with active ads until they have entered their payment details into the AdMob account. 我们已经收到用户的报告,尤其是使用AdMob的用户,他们的横幅广告直到他们在AdMob帐户中输入了付款明细之后才填充有效广告。 Update your AdMob account with your payment details and see if the issue resolves in 24 hours. 使用您的付款详细信息更新您的AdMob帐户,并查看问题是否会在24小时内解决。

  9. You've waited a few days, and have done all the above but the issue hasn't resolved. 您已经等待了几天,并完成了上述所有操作,但问题仍未解决。 Contact us, we are here to help. 与我们联系,我们在这里为您提供帮助。

Try to put your own app id here, not the one from the tutorial 尝试在此处放置您自己的应用ID,而不是教程中的ID

MobileAds.initialize(this, "ca-app-pub-3940256099942544~3347511713")

You can find your app id in the AdMob account that you created 您可以在创建的AdMob帐户中找到您的应用ID

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM