I am trying to integrate interstitial ads into my Android app using Google AdMob. I’ve followed the integration steps and used test ads as specified in the documentation. However, when running the app, I encounter errors in the logcat indicating that the interstitial ad fails to load due to “Unable to obtain a JavascriptEngine.” Below are the relevant code snippets and the error messages I’m seeing:
MobileAds.initialize(this) {}
// Set up the actual test device ID
val testDeviceIds = Arrays.asList("FC5ED3C0ADABF87230EA8348D65B072B")
val configuration = RequestConfiguration.Builder().setTestDeviceIds(testDeviceIds).build()
MobileAds.setRequestConfiguration(configuration)
loadInterstitialAd()
private fun loadInterstitialAd() {
try {
val adRequest = AdRequest.Builder().build()
InterstitialAd.load(this, "ca-app-pub-3940256099942544/1033173712", adRequest, object : InterstitialAdLoadCallback() {
override fun onAdFailedToLoad(adError: LoadAdError) {
Log.e("AdError", "Failed to load interstitial ad: ${adError.message}")
Handler(Looper.getMainLooper()).postDelayed({
loadInterstitialAd()
},30000)
}
override fun onAdLoaded(interstitialAd: InterstitialAd) {
super.onAdLoaded(interstitialAd)
mInterstitialAd = interstitialAd
Log.d("Ad", "Loaded")
showAd()
}
})
} catch (e:Exception) {
Log.e("GoogleAds","${e.message}")
}
}
private fun showAd(){
val TAG = "InterstitialAd"
mInterstitialAd?.fullScreenContentCallback = object: FullScreenContentCallback() {
override fun onAdClicked() {
// Called when a click is recorded for an ad.
Log.d(TAG, "Ad was clicked.")
}
override fun onAdDismissedFullScreenContent() {
// Called when ad is dismissed.
Log.d(TAG, "Ad dismissed fullscreen content.")
mInterstitialAd = null
}
override fun onAdFailedToShowFullScreenContent(adError: AdError) {
// Called when ad fails to show.
Log.e("InterstitialAd", "Ad failed to show fullscreen content: ${adError.message}")
mInterstitialAd = null
}
override fun onAdImpression() {
// Called when an impression is recorded for an ad.
Log.d(TAG, "Ad recorded an impression.")
}
override fun onAdShowedFullScreenContent() {
// Called when ad is shown.
Log.d(TAG, "Ad showed fullscreen content.")
}
}
mInterstitialAd?.show(this) ?: Log.d(TAG, "The interstitial ad wasn't ready yet.")
}
These are the Errors showing on logcat
chromium com.example.myApp E [ERROR:aw_browser_terminator.cc(166)] Renderer process (25616) crash detected (code -1).
AdError com.example.myApp E Failed to load interstitial ad: Unable to obtain a JavascriptEngine.
Ads com.example.myApp I Ad failed to load : 0
What I’ve Tried:
Confirmed that the AdMob app ID is correctly initialized.
Verified the test device ID is correctly added in the AdMob console.
Ensured that I’m using the correct test ad unit ID.
What might be causing the “Unable to obtain a JavascriptEngine” error when trying to load interstitial ads?
Are there additional configurations or permissions required that I might be missing?
Is there a known issue with the current version of the AdMob SDK that could be causing this error?
Any guidance or suggestions would be greatly appreciated!