问题描述
我只想使用测试ID来显示奖励视频广告",但加载时一次又一次失败.有人可以告诉我我做错了什么.这是我的主要活动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())
}
}
这是我在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"/>
权限.
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
这是我在build.gradle(项目:app_name)中写的那一行.
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
这是我在build.gradle(Module:app)中写的那一行.
implementation 'com.google.android.gms:play-services-ads:15.0.1'
以下是一些常见原因以及解决方法:
- 确保您已使用付款明细更新了AdMob
- 确保您在AdMob中创建的广告是横幅广告.
- 检查您的AdMob信息中心以查看广告的状态,它们是否处于活动状态?
- 验证您使用了正确的广告单元ID.
-
24小时提供服务可能需要一段时间才能使广告在您所在的地区生效另外请记住:
-
现在投放广告还为时过早.讲英语的地区往往会获得更快的填充率,因为有越来越多的广告商瞄准这些市场.市场越小,填充率就越慢.等待48小时,看看问题是否解决.
-
您所在地区的填充率较低.您会注意到自己正在赚钱,但是当您自己测试游戏时,您在游戏中看不到任何广告.您要测试的区域的填充率可能会降低,但是在您为其发布的其他区域中,广告仍然处于活动状态.请等待48个小时,您所在的区域应使用有效的广告进行更新.
-
您尚未输入付款明细.我们收到了一些用户的报告,尤其是使用AdMob的用户,他们的横幅广告直到他们在AdMob帐户中输入了付款明细之后才填充有效广告.使用付款明细更新您的AdMob帐户,并查看问题是否会在24小时内解决.
-
您已经等待了几天,并且已完成上述所有操作,但问题仍未解决.与我们联系,我们在这里为您提供帮助.
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.Here is my Main Activity 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.
<!-- 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).
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
Here is the line that I write in 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:
- Make sure you have updated AdMob with your payment details
- Make sure that the ads you created in AdMob are banner ads.
- Check your AdMob dashboard to see the status of your ads, are they active?
- Verify you used the correct Ad Unit Id.
Give it 24 hours, it can take time for an ad to become active in your regionAlso keep in mind:
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.
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.
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. Update your AdMob account with your payment details and see if the issue resolves in 24 hours.
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.
这篇关于为什么我的Admob奖励视频广告一次又一次无法加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!