Ads not showing and debugging
This project was based on below environment.
- Expo bare project (npx expo prebuild) with template TypeScript.
- expo: 54.0.23
- react-native: 0.81.5
- react-native-google-mobile-ads: 16.0.0
Suddenly Ads were not working! Yesterday they were all fine, all ads were showing correctly. But now Banner area empty, rewarded ads not loaded (if not loaded, gray inactivated button)
I didn't change anything from yesterday. No package added, no coding editied, it was same as before, but just 1day after, it's not working. I have banner, interstitial, rewarded ads but they all are not showing.
The first thing I tried was making bare project again. Simply erase android, ios folder and make it again with expo prebuild.
$ rm -rf android ios $ npx expo prebuild $ npx expo start:android
Ads still not showing. So this time I tried to wipe data in simulator and even delete the simulator and made it again.
Not working. I started to doubt about some AdMob server error, since I heard recently about several global network error like Cloudflare problem etc. It was just 1 week ago and maybe similar issue can happen again. This time I save the backup for my current App.tsx and changed it totally only for 1 simple banner as test and to see the error log.
App.tsx import React, { useEffect } from 'react'; import { View, Text, StyleSheet } from 'react-native'; import mobileAds, { BannerAd, BannerAdSize, TestIds, } from 'react-native-google-mobile-ads'; export default function App() { useEffect(() => { console.log('[AdMob] Initializing...'); mobileAds() .initialize() .then(adapterStatuses => { console.log('[AdMob] Initialization complete'); console.log('[AdMob] Adapter Status:', adapterStatuses); }) .catch(err => { console.log('[AdMob] Initialization Error:', err); }); }, []); const adUnitId = __DEV__ ? TestIds.BANNER : 'ca-app-pub-3940256099942544/6300978111'; return ( <View style={styles.container}> <Text style={styles.title}>AdMob Banner Debug Test</Text> <BannerAd unitId={adUnitId} size={BannerAdSize.BANNER} onAdLoaded={() => { console.log('[AdMob] Banner Loaded Successfully'); }} onAdFailedToLoad={(error) => { console.log('[AdMob] Banner Failed to Load:', error); }} onAdOpened={() => { console.log('[AdMob] Banner Opened'); }} onAdClosed={() => { console.log('[AdMob] Banner Closed'); }} /> </View> ); } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', padding: 20, }, title: { fontSize: 20, marginBottom: 20, fontWeight: '600', }, });
Android Bundled 556ms index.ts (808 modules) LOG [AdMob] Initializing... LOG [AdMob] Initialization complete LOG [AdMob] Adapter Status: [{"description": "Timeout.", "name": "com.google.android.gms.ads.MobileAds", "state": 0}] LOG [AdMob] Banner Failed to Load: [Error: [googleMobileAds/error-code-internal-error] Something happened internally; for instance, an invalid response was received from the ad server.] LOG [AdMob] Banner Failed to Load: [Error: [googleMobileAds/error-code-internal-error] Something happened internally; for instance, an invalid response was received from the ad server.]
SDK initialization was fine, but "description": "Timeout" means it was failed to communicate with AdMob server. Then the problem would be from my side, (simulator? or my laptop network?) or server side. From my side I already reset the simulator so that would not be a problem and I don't use any VPN or special firewall, it's just normal home network as before. I double-checked the app id, ads id and it was correct.
I started to believe that it would be definitely due to some server error so I watied for around several hours, waiting for something fixed and solved. Meantime I found out that my Macbook was in "Do not disrupt" mode, which was synchronized with my iPhone.
I had no idea, but hoping for miracle, I deactivated the "Do not disrupt" mode and restart my Mac. Then suddenly the ads appeared again!
Android Bundled 8269ms index.ts (808 modules) LOG [AdMob] Initializing... LOG [AdMob] Initialization complete LOG [AdMob] Adapter Status: [{"description": "", "name": "com.google.android.gms.ads.MobileAds", "state": 1}] LOG [AdMob] Banner Loaded Successfully
I don't know how the "Do not disrupt" mode would have impact on Ads. That mode is just for mute of some notification, isn't it? I see no technical connection between them. I checked it further with ChatGPT and it might be restart my Mac solve the problem, because it would be due to some environment problem in my side, simulator, network etc. etc. and it was reset after my Mac restarted.
Well I can't understand it quite well but any way, this time I learned some lesson. Sometimes just restart my Mac will solve it.
Comments
Post a Comment