I’m working on an Android app using Jetpack Compose and I’m trying to show an interstitial ad using InterstitialAd.show(context as Activty) inside a composable screen. However, I’m getting a crash when casting LocalContext.current to Activity in order to call the show() method for the ad. This crash started occurring after I updated the compileSdkVersion and targetSdkVersion to 35.
Eception:
Unable to find explicit activity class {com.zz.zzworld/com.google.android.gms.ads.AdActivity}; have you declared this activity in your AndroidManifest.xml, or does your intent not match its declared ?
Here’s the code I’m using to cast the context and display the ad:
InterstitialAds.getInstance().mInterstitialAd?.show(context as Activity)
1