I have implemented banner ads and reward interstitial ads in my main activity page for an Android app on Android studio. Moreover, I tend to load reward interstitial ads whenever Search function is performed five times. However, only banner ads work and loaded while all reward interstitial ads are encountering issues such as
Ad failed to load : 3
or
Not retrying to fetch app settings
I have tried all the AppUnit ID for both real ID, and test ID provided by AdMob also. Only reward interstitial ads are not able to load. But I do not have physical device to test. All the tests are done on Simulator device.
This is my main page
MainActivity.kt
class MainActivity : AppCompatActivity() {
lateinit var mAdView : AdView
private var adLoaded = false
lateinit var mAdView : AdView
private var searchCount = 0
private lateinit var rewardedInterstitialAd: RewardedInterstitialAd
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
//Banner Ads
MobileAds.initialize(this) {}
//Load Reward Interstitial Ads
loadRewardedInterstitialAd()
mAdView = findViewById(R.id.adView)
val adRequestb = AdRequest.Builder().build()
mAdView.loadAd(adRequestb)
}
private fun performSearch(query: String) {
val lowercaseQuery = query.lowercase(Locale.ROOT)
if (lowercaseQuery.isBlank()) {
// If the query is blank, show an empty list
displayresult.clear()
} else {
// Perform the search and update the display result list
displayresult.clear()
results.forEach { result ->
if (
//Search function
}
}
}
currentPage = 0
updateListView()
searchCount++
if (searchCount % 5 == 0 && adLoaded) {
rewardedInterstitialAd.show(this) {
Log.d(TAG, "Rewarded Interstitial Ad was shown.")
}
} else {
Log.d(TAG, "Search count reached but no add.")
}
}
private fun loadRewardedInterstitialAd() {
val adManagerAdRequest = AdManagerAdRequest.Builder().build()
RewardedInterstitialAd.load(
this,
"0000000000000000000", //AdUnit ID
adManagerAdRequest,
object : RewardedInterstitialAdLoadCallback() {
override fun onAdLoaded(ad: RewardedInterstitialAd) {
rewardedInterstitialAd = ad
adLoaded = true
Log.d(TAG, "Rewarded Interstitial Ad was loaded.")
}
override fun onAdFailedToLoad(loadAdError: LoadAdError) {
Log.d(TAG, "Rewarded Interstitial Ad failed to load.")
}
}
)
}
}