Home > Software engineering >  Admob test ad not always showing (Flutter)
Admob test ad not always showing (Flutter)

Time:08-21

i am trying to implent test ads on my Flutter app. So far, what i notice is that 3 out of 4 times my test ad rewarded video are showing, but sometimes they are not. This is what i am getting when the video is not loading. Since the other times the video laods, i don't think that is a setup problem, but i am attaching my code.

This is the error: (Real device, Samsung Galaxy S10)

I/DynamiteModule( 9385): Considering local module com.google.android.gms.ads.dynamite:0 and remote module com.google.android.gms.ads.dynamite:221908400
I/DynamiteModule( 9385): Selected remote version of com.google.android.gms.ads.dynamite, version >= 221908400
V/DynamiteModule( 9385): Dynamite loader version >= 2, using loadModule2NoCrashUtils
I/Ads     ( 9385): Use RequestConfiguration.Builder().setTestDeviceIds(Arrays.asList("57D8CCEE680443B3894B93AB5E6F61C8")) to get test ads on this device.
W/Ads     ( 9385): Not retrying to fetch app settings
I/ViewRootImpl@563214[MainActivity]( 9385): ViewPostIme pointer 0
I/ViewRootImpl@563214[MainActivity]( 9385): ViewPostIme pointer 1
I/ExoPlayerImpl( 9385): Init ExoPlayerLib/2.4.2 [beyond1, SM-G973F, samsung, 31]
D/MetadataUtil( 9385): Skipped unknown metadata entry: gsst
D/MetadataUtil( 9385): Skipped unknown metadata entry: gstd
I/CCodec  ( 9385): state->set(ALLOCATING)
I/CCodec  ( 9385): allocate(c2.android.aac.decoder)
I/CCodec  ( 9385): setting up 'default' as default (vendor) store
I/CCodec  ( 9385): Created component [c2.android.aac.decoder]
I/CCodec  ( 9385): state->set(ALLOCATED)
D/CCodecConfig( 9385): read media type: audio/mp4a-latm
D/ReflectedParamUpdater( 9385): extent() != 1 for single value type: algo.buffers.max-count.values
D/ReflectedParamUpdater( 9385): extent() != 1 for single value type: output.subscribed-indices.values
D/ReflectedParamUpdater( 9385): extent() != 1 for single value type: input.buffers.allocator-ids.values
D/ReflectedParamUpdater( 9385): extent() != 1 for single value type: output.buffers.allocator-ids.values
D/ReflectedParamUpdater( 9385): extent() != 1 for single value type: algo.buffers.allocator-ids.values
D/ReflectedParamUpdater( 9385): extent() != 1 for single value type: output.buffers.pool-ids.values
D/ReflectedParamUpdater( 9385): extent() != 1 for single value type: algo.buffers.pool-ids.values
I/CCodecConfig( 9385): query failed after returning 19 values (BAD_INDEX)
D/CCodecConfig( 9385): c2 config diff is Dict {
D/CCodecConfig( 9385):   c2::u32 coded.aac-packaging.value = 0
D/CCodecConfig( 9385):   c2::u32 coded.bitrate.value = 64000
D/CCodecConfig( 9385):   c2::u32 coded.pl.level = 0
D/CCodecConfig( 9385):   c2::u32 coded.pl.profile = 8192
D/CCodecConfig( 9385):   c2::i32 coding.drc.album-mode.value = 0
D/CCodecConfig( 9385):   c2::float coding.drc.attenuation-factor.value = 1
D/CCodecConfig( 9385):   c2::float coding.drc.boost-factor.value = 1
D/CCodecConfig( 9385):   c2::i32 coding.drc.compression-mode.value = 3
D/CCodecConfig( 9385):   c2::i32 coding.drc.effect-type.value = 3
D/CCodecConfig( 9385):   c2::float coding.drc.encoded-level.value = 0.25
D/CCodecConfig( 9385):   c2::float coding.drc.reference-level.value = -16
D/CCodecConfig( 9385):   c2::u32 input.buffers.max-size.value = 8192
D/CCodecConfig( 9385):   c2::u32 input.delay.value = 0
D/CCodecConfig( 9385):   string input.media-type.value = "audio/mp4a-latm"
D/CCodecConfig( 9385):   c2::u32 output.delay.value = 2
D/CCodecConfig( 9385):   c2::float output.drc.output-loudness.value = 0.25
D/CCodecConfig( 9385):   string output.media-type.value = "audio/raw"
D/CCodecConfig( 9385):   c2::u32 raw.channel-count.value = 1
D/CCodecConfig( 9385):   c2::u32 raw.max-channel-count.value = 8
D/CCodecConfig( 9385):   c2::u32 raw.sample-rate.value = 44100
D/CCodecConfig( 9385): }
D/CCodec  ( 9385): [c2.android.aac.decoder] buffers are bound to CCodec for this session
I/CCodec  ( 9385): appPid(9385) width(0) height(0)
D/CCodecConfig( 9385): no c2 equivalents for language
D/CCodecConfig( 9385): no c2 equivalents for flags
D/CCodecConfig( 9385): config failed => CORRUPTED
D/CCodecConfig( 9385): c2 config diff is   c2::u32 raw.channel-count.value = 2
W/Codec2Client( 9385): query -- param skipped: index = 1107298332.
D/CCodec  ( 9385): client requested max input size 540, which is smaller than what component recommended (8192); overriding with component recommendation.
W/CCodec  ( 9385): This behavior is subject to change. It is recommended that app developers double check whether the requested max input size is in reasonable range.
D/CCodec  ( 9385): setup formats input: AMessage(what = 0x00000000) = {
D/CCodec  ( 9385):   int32_t aac-drc-album-mode = 0
D/CCodec  ( 9385):   int32_t aac-drc-boost-level = 127
D/CCodec  ( 9385):   int32_t aac-drc-cut-level = 127
D/CCodec  ( 9385):   int32_t aac-drc-effect-type = 3
D/CCodec  ( 9385):   int32_t aac-encoded-target-level = -1
D/CCodec  ( 9385):   int32_t aac-max-output-channel_count = 8
D/CCodec  ( 9385):   int32_t aac-target-ref-level = 64
D/CCodec  ( 9385):   int32_t bitrate = 64000
D/CCodec  ( 9385):   int32_t channel-count = 2
D/CCodec  ( 9385):   int32_t level = 0
D/CCodec  ( 9385):   int32_t max-input-size = 8192
D/CCodec  ( 9385):   string mime = "audio/mp4a-latm"
D/CCodec  ( 9385):   int32_t profile = 2
D/CCodec  ( 9385):   int32_t sample-rate = 44100
D/CCodec  ( 9385):   int64_t durationUs = 0
D/CCodec  ( 9385): }
D/CCodec  ( 9385): setup formats output: AMessage(what = 0x00000000) = {
D/CCodec  ( 9385):   int32_t aac-drc-album-mode = 0
D/CCodec  ( 9385):   int32_t aac-drc-boost-level = 127
D/CCodec  ( 9385):   int32_t aac-drc-cut-level = 127
D/CCodec  ( 9385):   int32_t aac-drc-effect-type = 3
D/CCodec  ( 9385):   int32_t aac-drc-output-loudness = -1
D/CCodec  ( 9385):   int32_t aac-encoded-target-level = -1
D/CCodec  ( 9385):   int32_t aac-max-output-channel_count = 8
D/CCodec  ( 9385):   int32_t aac-target-ref-level = 64
D/CCodec  ( 9385):   int32_t channel-count = 2
D/CCodec  ( 9385):   string mime = "audio/raw"
D/CCodec  ( 9385):   int32_t sample-rate = 44100
D/CCodec  ( 9385): }
I/CCodecConfig( 9385): query failed after returning 19 values (BAD_INDEX)
I/CCodec  ( 9385): state->set(STARTING)
W/Codec2Client( 9385): query -- param skipped: index = 1342179345.
W/Codec2Client( 9385): query -- param skipped: index = 2415921170.
W/Codec2Client( 9385): query -- param skipped: index = 1610614798.
D/CCodecBufferChannel( 9385): [c2.android.aac.decoder#324] Created input block pool with allocatorID 16 => poolID 48 - OK (0)
I/CCodecBufferChannel( 9385): [c2.android.aac.decoder#324] Created output block pool with allocatorID 16 => poolID 277 - OK
D/CCodecBufferChannel( 9385): [c2.android.aac.decoder#324] Configured output block pool ids 277 => OK
I/CCodec  ( 9385): state->set(RUNNING)
I/CCodecBufferChannel( 9385): [c2.android.aac.decoder#324] 4 initial input buffers available
I/ACodec  ( 9385):  [] Now uninitialized
I/ACodec  ( 9385): [] onAllocateComponent
I/OMXClient( 9385): IOmx service obtained
E/ACodec  ( 9385): Unable to instantiate codec 'OMX.Exynos.avc.dec' with err 0xfffffff4.
E/ACodec  ( 9385): signalError(omxError 0xfffffff4, internalError -12)
E/MediaCodec( 9385): Codec reported err 0xfffffff4, actionCode 0, while in state 1/INITIALIZING
W/MediaCodec-JNI( 9385): try to release MediaCodec from JMediaCodec::~JMediaCodec()...
W/MediaCodec-JNI( 9385): done releasing MediaCodec from JMediaCodec::~JMediaCodec().
E/ExoPlayerImplInternal( 9385): Renderer error.
E/ExoPlayerImplInternal( 9385): com.google.android.gms.ads.exoplayer3.c
E/ExoPlayerImplInternal( 9385):     at com.google.android.gms.ads.exoplayer3.mediacodec.c.N(:com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:20)
E/ExoPlayerImplInternal( 9385):     at com.google.android.gms.ads.exoplayer3.mediacodec.c.G(:com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:4)
E/ExoPlayerImplInternal( 9385):     at com.google.android.gms.ads.exoplayer3.video.h.G(:com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:1)
E/ExoPlayerImplInternal( 9385):     at com.google.android.gms.ads.exoplayer3.mediacodec.c.z(:com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:3)
E/ExoPlayerImplInternal( 9385):     at com.google.android.gms.ads.exoplayer3.n.handleMessage(:com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:42)
E/ExoPlayerImplInternal( 9385):     at android.os.Handler.dispatchMessage(Handler.java:102)
E/ExoPlayerImplInternal( 9385):     at android.os.Looper.loopOnce(Looper.java:226)
E/ExoPlayerImplInternal( 9385):     at android.os.Looper.loop(Looper.java:313)
E/ExoPlayerImplInternal( 9385):     at android.os.HandlerThread.run(HandlerThread.java:67)
E/ExoPlayerImplInternal( 9385): Caused by: com.google.android.gms.ads.exoplayer3.mediacodec.b: Decoder init failed: OMX.Exynos.avc.dec, Format(1, null, video/avc, -1, null, [1280, 720, -1.0], [-1, -1])
E/ExoPlayerImplInternal( 9385):     at com.google.android.gms.ads.exoplayer3.mediacodec.c.N(:com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:19)
E/ExoPlayerImplInternal( 9385):     ... 8 more
E/ExoPlayerImplInternal( 9385): Caused by: android.media.MediaCodec$CodecException: Failed to initialize OMX.Exynos.avc.dec, error 0xfffffff4
E/ExoPlayerImplInternal( 9385):     at android.media.MediaCodec.native_setup(Native Method)
E/ExoPlayerImplInternal( 9385):     at android.media.MediaCodec.<init>(MediaCodec.java:1961)
E/ExoPlayerImplInternal( 9385):     at android.media.MediaCodec.createByCodecName(MediaCodec.java:1938)
E/ExoPlayerImplInternal( 9385):     at com.google.android.gms.ads.exoplayer3.mediacodec.c.N(:com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:9)
E/ExoPlayerImplInternal( 9385):     ... 8 more
I/CCodec  ( 9385): state->set(STOPPING)
D/CCodecBufferChannel( 9385): [c2.android.aac.decoder#324] MediaCodec discarded an unknown buffer
W/Ads     ( 9385): Precache error
W/Ads     ( 9385): com.google.android.gms.ads.exoplayer3.c
W/Ads     ( 9385):  at com.google.android.gms.ads.exoplayer3.mediacodec.c.N(:com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:20)
W/Ads     ( 9385):  at com.google.android.gms.ads.exoplayer3.mediacodec.c.G(:com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:4)
W/Ads     ( 9385):  at com.google.android.gms.ads.exoplayer3.video.h.G(:com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:1)
W/Ads     ( 9385):  at com.google.android.gms.ads.exoplayer3.mediacodec.c.z(:com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:3)
W/Ads     ( 9385):  at com.google.android.gms.ads.exoplayer3.n.handleMessage(:com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:42)
W/Ads     ( 9385):  at android.os.Handler.dispatchMessage(Handler.java:102)
W/Ads     ( 9385):  at android.os.Looper.loopOnce(Looper.java:226)
W/Ads     ( 9385):  at android.os.Looper.loop(Looper.java:313)
W/Ads     ( 9385):  at android.os.HandlerThread.run(HandlerThread.java:67)
W/Ads     ( 9385): Caused by: com.google.android.gms.ads.exoplayer3.mediacodec.b: Decoder init failed: OMX.Exynos.avc.dec, Format(1, null, video/avc, -1, null, [1280, 720, -1.0], [-1, -1])
W/Ads     ( 9385):  at com.google.android.gms.ads.exoplayer3.mediacodec.c.N(:com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:19)
W/Ads     ( 9385):  ... 8 more
W/Ads     ( 9385): Caused by: android.media.MediaCodec$CodecException: Failed to initialize OMX.Exynos.avc.dec, error 0xfffffff4
W/Ads     ( 9385):  at android.media.MediaCodec.native_setup(Native Method)
W/Ads     ( 9385):  at android.media.MediaCodec.<init>(MediaCodec.java:1961)
W/Ads     ( 9385):  at android.media.MediaCodec.createByCodecName(MediaCodec.java:1938)
W/Ads     ( 9385):  at com.google.android.gms.ads.exoplayer3.mediacodec.c.N(:com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:9)
W/Ads     ( 9385):  ... 8 more
D/CCodecBufferChannel( 9385): [c2.android.aac.decoder#324] MediaCodec discarded an unknown buffer
D/CCodecBufferChannel( 9385): [c2.android.aac.decoder#324] MediaCodec discarded an unknown buffer
D/CCodecBufferChannel( 9385): [c2.android.aac.decoder#324] MediaCodec discarded an unknown buffer
D/CCodecBufferChannel( 9385): [c2.android.aac.decoder#324] MediaCodec discarded an unknown buffer
D/CCodecBufferChannel( 9385): [c2.android.aac.decoder#324] MediaCodec discarded an unknown buffer
D/CCodecBufferChannel( 9385): [c2.android.aac.decoder#324] MediaCodec discarded an unknown buffer
D/CCodecBufferChannel( 9385): [c2.android.aac.decoder#324] MediaCodec discarded an unknown buffer
I/CCodec  ( 9385): state->set(ALLOCATED)
I/CCodec  ( 9385): state->set(RELEASING)
I/CCodec  ( 9385): [c2.android.aac.decoder] release(1)
I/CCodec  ( 9385): state->set(RELEASED)
I/hw-BpHwBinder( 9385): onLastStrongRef automatically unlinking death recipients
I/MediaCodec( 9385): Codec shutdown complete
I/ViewRootImpl@563214[MainActivity]( 9385): ViewPostIme pointer 0
I/ViewRootImpl@563214[MainActivity]( 9385): ViewPostIme pointer 1
D/BufferPoolAccessor2.0( 9385): bufferpool2 0x777c2d7a08 : 0(0 size) total buffers - 0(0 size) used buffers - 1/6 (recycle/alloc) - 5/8 (fetch/transfer)
D/BufferPoolAccessor2.0( 9385): evictor expired: 1, evicted: 1
I/ViewRootImpl@563214[MainActivity]( 9385): ViewPostIme pointer 0
I/ViewRootImpl@563214[MainActivity]( 9385): ViewPostIme pointer 1
D/BufferPoolAccessor2.0( 9385): evictor expired: 1, evicted: 0
D/BufferPoolAccessor2.0( 9385): bufferpool2 0x777c3571a8 : 0(0 size) total buffers - 0(0 size) used buffers - 1/6 (recycle/alloc) - 5/8 (fetch/transfer)
D/BufferPoolAccessor2.0( 9385): evictor expired: 1, evicted: 1
I/pestini.essenc( 9385): Background concurrent copying GC freed 573699(23MB) AllocSpace objects, 4(80KB) LOS objects, 43% free, 30MB/54MB, paused 232us,136us total 120.237ms
I/Ads     ( 9385): Ad failed to load : 0
I/flutter ( 9385): Failed to load a rewarded ad: Internal error.
W/Ads     ( 9385): Failed to preload url gcache://video/media/8744318498482049952?url=https://rr1---sn-uxaxpu5ap5-apol.googlevideo.com/videoplayback?expire=1661099020&ei=jOsBY_yGIor_gAehs6ow&ip=79.21.162.29&id=795a0f5850e653a0&itag=22&source=youtube&requiressl=yes&mh=LS&mm=31&mn=sn-uxaxpu5ap5-apol&ms=au&mv=m&mvi=1&pl=24&susc=gvp&acao=yes&ctier=L&mime=video%2Fmp4&vprv=1&dur=5.038&lmt=1606000670604054&mt=1661069832&txp=1211222&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Csusc%2Cacao%2Cctier%2Cmime%2Cvprv%2Cdur%2Clmt&sig=AOq0QJ8wRQIgGnvHqkqA7FF7lDY492LRjEjdWvBXmcPJ7xXW7TyqniICIQDPrVizMFRdNZ_sfM9-LixHUPOCGqZuFQiFX131KzmH4w%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl&lsig=AG3C_xAwRQIgVaTrgTmchNN6aeKKZ3jqu_Jn8ufCI8Rc0FS9eq4kMLMCIQDRyVb6NYdv4le9BEjPs4N8loanOFOPpM27bOZ22ZM2gQ%3D%3D&cpn=nVl-a3BtlRhfCqIr&ic=gmasdk&tag.duration=5038&tag.check_url=https://rr1---sn-uxaxpu5ap5-apol.googlevideo.com/videoplayback?expire=1661099020&ei=jOsBY_yGIor_gAehs6ow&ip=79.21.162.29&id=795a0f5850e653a0&itag=22&source=youtube&requiressl=yes&mh=LS&mm=31&mn=sn-uxaxpu5ap5-apol&ms=au&mv=m&mvi=1&pl=24&susc=gvp&acao=yes&ctier=L&mime=video/mp4&vprv=1&dur=5.038&lmt=1606000670604054&mt=1661069832&txp=1211222&sparams=expire,ei,ip,id,itag,source,requiressl,susc,acao,ctier,mime,vprv,dur,lmt&sig=AOq0QJ8wRQIgGnvHqkqA7FF7lDY492LRjEjdWvBXmcPJ7xXW7TyqniICIQDPrVizMFRdNZ_sfM9-LixHUPOCGqZuFQiFX131KzmH4w==&lsparams=mh,mm,mn,ms,mv,mvi,pl&lsig=AG3C_xAwRQIgVaTrgTmchNN6aeKKZ3jqu_Jn8ufCI8Rc0FS9eq4kMLMCIQDRyVb6NYdv4le9BEjPs4N8loanOFOPpM27bOZ22ZM2gQ==&cpn=nVl-a3BtlRhfCqIr Exception: ExoPlayer was released during preloading.
W/Ads     ( 9385): #004 The webview is destroyed. Ignoring action.
W/Ads     ( 9385): Failed to preload url gcache://video/media/-438303185308675417?url=https://rr2---sn-uxaxpu5ap5-apol.googlevideo.com/videoplayback?expire=1661098796&ei=rOoBY-STOoXix_APlPi-sAI&ip=79.21.162.29&id=f9ead5933fc112a7&itag=22&source=youtube&requiressl=yes&mh=EA&mm=31&mn=sn-uxaxpu5ap5-apol&ms=au&mv=m&mvi=2&pcm2cms=yes&pl=24&susc=gvp&acao=yes&ctier=L&mime=video%2Fmp4&vprv=1&dur=7.267&lmt=1609247274254961&mt=1661069127&txp=1211222&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Csusc%2Cacao%2Cctier%2Cmime%2Cvprv%2Cdur%2Clmt&sig=AOq0QJ8wRQIhAKtTUzu10duuyNKA-tGUC1RWgchGK_uGHSDZdrav3sdGAiBCwnEMg6POUb_KHgvB6F8pf_4KmvyXoLJhS3_q8b-Iug%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpcm2cms%2Cpl&lsig=AG3C_xAwRAIgTTAj7kuZyg1hKG_X6a9PcblwqoCCmRioT58RU7RQGccCIB7KyWOT9_iD5cpwMF9gEGrUgKNYFgees0Wxq_VTQeca&cpn=Kwm_j2j_MqowGqx3&ic=gmasdk&tag.duration=7267&tag.check_url=https://rr2---sn-uxaxpu5ap5-apol.googlevideo.com/videoplayback?expire=1661098796&ei=rOoBY-STOoXix_APlPi-sAI&ip=79.21.162.29&id=f9ead5933fc112a7&itag=22&source=youtube&requiressl=yes&mh=EA&mm=31&mn=sn-uxaxpu5ap5-apol&ms=au&mv=m&mvi=2&pcm2cms=yes&pl=24&susc=gvp&acao=yes&ctier=L&mime=video/mp4&vprv=1&dur=7.267&lmt=1609247274254961&mt=1661069127&txp=1211222&sparams=expire,ei,ip,id,itag,source,requiressl,susc,acao,ctier,mime,vprv,dur,lmt&sig=AOq0QJ8wRQIhAKtTUzu10duuyNKA-tGUC1RWgchGK_uGHSDZdrav3sdGAiBCwnEMg6POUb_KHgvB6F8pf_4KmvyXoLJhS3_q8b-Iug==&lsparams=mh,mm,mn,ms,mv,mvi,pcm2cms,pl&lsig=AG3C_xAwRAIgTTAj7kuZyg1hKG_X6a9PcblwqoCCmRioT58RU7RQGccCIB7KyWOT9_iD5cpwMF9gEGrUgKNYFgees0Wxq_VTQeca&cpn=Kwm_j2j_MqowGqx3 Exception: Timeout reached. Limit: 300000 ms

This is how i implemented rewared video test ads.

bool _isRewardedAdReady = false;
RewardedAd? _rewardedAd;

  void _loadRewardedAd() {
    RewardedAd.load(
      adUnitId: AdHelper.rewardedAdUnitId,
      request: AdRequest(),
      rewardedAdLoadCallback: RewardedAdLoadCallback(
        onAdLoaded: (ad) {
          _rewardedAd = ad;

          ad.fullScreenContentCallback = FullScreenContentCallback(
            onAdDismissedFullScreenContent: (ad) {
              setState(() {
                _isRewardedAdReady = false;
              });
              _loadRewardedAd();
            },
          );

          setState(() {
            _isRewardedAdReady = true;
          });
        },
        onAdFailedToLoad: (err) {
          print('Failed to load a rewarded ad: ${err.message}');
          setState(() {
            _isRewardedAdReady = false;
          });
        },
      ),
    );
  }

  @override
  void initState() {
    super.initState();
    _loadRewardedAd();
  }

  @override
  void dispose() {
    _rewardedAd?.dispose();
    super.dispose();
  }

On the widget, i want to use to display the ad, i have this code

if (isRewardedAdReady) {
                        rewardedAd?.show(onUserEarnedReward:
                            (AdWithoutView ad, RewardItem reward) {
                          print(
                              '$ad with reward $RewardItem(${reward.amount}, ${reward.type}');
                        });
                      }

CodePudding user response:

The implementation looks correct. You can may be check if the rewarded video is loaded or not before you load a new one..

if(isRewardedAdReady == false)
{
  load a new ad here;
}

Also When you open the screen on which you wish to show the ad first load the ad and keep it ready. Then when you wish to display it check if its ready and display it. That gives you some time to load the ad. In the current implementation I see that you are setting state of isRewardedAdReady and that will trigger showing the ad immediately the ad is ready(unless they are implemented differently, sorry if I am wrong). Also please check the variables _isRewardedAdReady and isRewardedAdReady are they same or different (notice you missed the underscore). Since you mentioned that it is displaying ads properly you may also try on other devices or simulator too.

CodePudding user response:

The way to solve it is to update RequestConfiguration with the testDeviceIds

String version;
  List<String> testDeviceIds = ['289C....E6'];

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  timeDilation = 1;
  PackageInfo packageInfo = await PackageInfo.fromPlatform();
  version = packageInfo.version;
  MobileAds.instance.initialize();

  // thing to add
  RequestConfiguration configuration =
       RequestConfiguration(testDeviceIds: testDeviceIds);
  MobileAds.instance.updateRequestConfiguration(configuration);


  await Firebase.initializeApp();
  runApp(MyApp());
}

How to get TestDeviceIDs

If you want to test ads in your app as you're developing.

  1. Load your ads-integrated app and make an ad request.
  2. Check the logcat output for a message that looks like the one below, which shows you your device ID and how to add it as a test device:

Use RequestConfiguration.Builder().setTestDeviceIds(Arrays.asList("289.......E6") to get test ads on this device.

  1. Add the device ID that your logcat gave you in the terminal, and use it as testDeviceId
  • Related