Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: cannot find symbol import com.google.android.gms.ads.InterstitialAd

I had added google AdMob to the project and found this error : error: cannot find symbol import com.google.android.gms.ads.InterstitialAd; ^ symbol: class InterstitialAd location: package com.google.android.gms.ads

like image 915
Mostafa Hydarzadeh Avatar asked May 12 '26 18:05

Mostafa Hydarzadeh


2 Answers

If you get this error after updating your com.google.android.gms:play-services-ads dependency to a more recent version, know that importing com.google.android.gms.ads.InterstitialAd has been deprecated since version 19.7.0 and has since been totally removed.

The new import should be:

import com.google.android.gms.ads.interstitial.InterstitialAd;

Either revert com.google.android.gms:play-services-ads to a version pre-19.7.0 or update your code by following the documentation here: https://developers.google.com/admob/android/interstitial.

like image 122
Touré Holder Avatar answered May 14 '26 08:05

Touré Holder


I found the answer : add this codes to build.gradle(app) (in the android tag )


configurations.all {
  resolutionStrategy {
    force "com.google.android.gms:play-services-basement:17.0.0"
    force "com.google.android.gms:play-services-base:17.1.0"
    force "com.google.android.gms:play-services-stats:17.0.0"
    force "com.google.android.gms:play-services-gcm:17.0.0"
    force "com.google.android.gms:play-services-ads:22.6.0"
 }
}

and if you had use of admob in the one library add codes above to library gradle too

like image 22
Mostafa Hydarzadeh Avatar answered May 14 '26 09:05

Mostafa Hydarzadeh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!