javaadmobadmob-rewardedvideoadsketchware

Java.lang.verifyerror when using admob rewarded ads


Whenever I opened my app it is crashing and shows below error Error image

I have noticed that it is occurring when I use admob rewarded ads code pls anyone help. Thank you


Solution

  • Try to use updated admob sdk.

        implementation 'com.google.android.gms:play-services-ads:20.1.0'
    
    
    //class will implements OnUserEarnedRewardListener
    
        private RewardedInterstitialAd rewardedInterstitialAd;
    
     @Override
    public void onUserEarnedReward(@NonNull RewardItem rewardItem) {
        Log.i(TAG, "onUserEarnedReward");
        // TODO: Reward the user!
    }
    
    public void loadRewardedAd() {
        // Use the test ad unit ID to load an ad.
        RewardedInterstitialAd.load(MainActivity.this, getString(R.string.rewarded_interstitial_id),
                new AdRequest.Builder().build(), new RewardedInterstitialAdLoadCallback() {
                    @Override
                    public void onAdLoaded(RewardedInterstitialAd ad) {
                        rewardedInterstitialAd = ad;
                        rewardedInterstitialAd.setFullScreenContentCallback(new FullScreenContentCallback() {
                            /** Called when the ad failed to show full screen content. */
                            @Override
                            public void onAdFailedToShowFullScreenContent(AdError adError) {
                                Log.i(TAG, "onAdFailedToShowFullScreenContent");
                            }
    
                            /** Called when ad showed the full screen content. */
                            @Override
                            public void onAdShowedFullScreenContent() {
                                Log.i(TAG, "onAdShowedFullScreenContent");
                            }
    
                            /** Called when full screen content is dismissed. */
                            @Override
                            public void onAdDismissedFullScreenContent() {
                                Log.i(TAG, "onAdDismissedFullScreenContent");
                            }
    
                        });
                    }
    
                    @Override
                    public void onAdFailedToLoad(LoadAdError loadAdError) {
                        Log.e(TAG, "onAdFailedToLoad");
                    }
                });
    }