'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



Solution 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Touré Holder