虽然测试广告有效,但我的广告移动单元无法使用

时间:2018-04-01 20:35:23

标签: kotlin admob

当我切换到测试广告单元时,它可以正常工作,当我切换回我的广告移动单元时(参考奖励视频广告),没有任何内容。

横幅有效,插页式广告,奖励视频也不起作用,我已经等了2天了。

我尝试使用谷歌的测试广告,它有效,当我添加我的时,它不起作用,即使我添加了我的测试设备,仍然无效。

我的来源:

package com.example.h1xpc.litecoinvault    
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.TextView
import com.google.android.gms.ads.*

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 {
    private lateinit var mRewardedVideoAd: RewardedVideoAd
    private var mText: TextView? = null
    private var currentLevel: Int = 0
    private var start_level:Int= 0
    private lateinit var mInterstitialAd: InterstitialAd
    private lateinit var mAdView: AdView
    val request = AdRequest.Builder()
            .addTestDevice("FDA90AA627BE640EF1DDD475EE720EDA")  

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

        currentLevel = start_level.toInt()

        mText = findViewById<View>(R.id.fx) as TextView

        val adView = AdView(this)
        adView.adSize = AdSize.BANNER
        adView.adUnitId = "ca-app-pub-1423729077793422/2760428620"


//For the ads
        MobileAds.initialize(this, "ca-app-pub-1423729077793422~2794990168")

        mAdView = findViewById(R.id.adView)
        val adRequest = AdRequest.Builder().build()
        mAdView.loadAd(adRequest)   

        mRewardedVideoAd = MobileAds.getRewardedVideoAdInstance(this)
        mRewardedVideoAd.rewardedVideoAdListener = this

        loadRewardedVideoAd()   

        //Second Ad 

    }

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

    fun startVideoAd(view: View) {

        if (mRewardedVideoAd.isLoaded) {
            mRewardedVideoAd.show()
        }
    }

    override fun onRewardedVideoAdLoaded() {

    }

    override fun onRewardedVideoAdOpened() {

    }

    override fun onRewardedVideoStarted() {

    }

    override fun onRewardedVideoAdClosed() {

        loadRewardedVideoAd()

    }

    override fun onRewarded(rewardItem: RewardItem) {

        mText!!.text = "COINS:" + (++currentLevel)

    }
    override fun onRewardedVideoAdLeftApplication() {    
    }

    override fun onRewardedVideoAdFailedToLoad(i: Int) {    
    }

    override fun onPause() {
        mRewardedVideoAd.pause(this)
        super.onPause()
    }

    override fun onResume() {

        mRewardedVideoAd.resume(this)
        super.onResume()
    }

    override fun onDestroy() {
        mRewardedVideoAd.destroy(this)
        super.onDestroy()
    }

    override fun onRewardedVideoCompleted() {    

    }    
}

1 个答案:

答案 0 :(得分:0)

试试这个。

val adRequest = AdRequest.Builder()。addTestDevice(&#34; FDA90AA627BE640EF1DDD475EE720EDA&#34;)。build();

另请分享错误代码。