简体   繁体   中英

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

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");
                }
            });
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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