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
Asked
Active
Viewed 9,345 times
2 Answers
8
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.

Touré Holder
- 2,768
- 2
- 22
- 20
7
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:19.7.0"
}
}
and if you had use of admob in the one library add codes above to library gradle too

Mostafa Hydarzadeh
- 165
- 2
- 9