googleads-mobile-flutter: [Android] Using `await MobileAds.instance.initialize()` the app fails to load
Plugin Version
google_mobile_ads: ^0.13.6
Steps to Reproduce
Create an app with async main
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await MobileAds.instance.initialize(); //get stuck on this line
..... it does not reach this line
}
Expected results: Do not get stuck the app. Yesterday my apps was working fine on the store. Today all apps do not open because of this problem. I did not make changes on my apps. Happens without any reason since yesterday. Solution was remove “await” word but I have to wait until my users update the apps.
Actual results: They get stuck on that line
Logs
[ ] executing: /Users/leonardo/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell am force-stop com.novenayvillancicos.santorosariocatolico
[ +56 ms] executing: /Users/leonardo/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell pm list packages com.novenayvillancicos.santorosariocatolico
[ +58 ms] package:com.novenayvillancicos.santorosariocatolico
[ +1 ms] executing: /Users/leonardo/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell cat /data/local/tmp/sky.com.novenayvillancicos.santorosariocatolico.sha1
[ +42 ms] ce716c55c6c4bcb0ffc9f7ccce084b4aeff393b7
[ ] Installing APK.
[ +1 ms] Installing build/app/outputs/flutter-apk/app.apk...
[ ] executing: /Users/leonardo/Library/Android/sdk/platform-tools/adb -s emulator-5554 install -t -r /Users/leonardo/Development/flutter/git/santorosario_flutter/build/app/outputs/flutter-apk/app.apk
[+1250 ms] Performing Streamed Install
Success
[ +1 ms] Installing build/app/outputs/flutter-apk/app.apk... (completed in 1,250ms)
[ +1 ms] executing: /Users/leonardo/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell echo -n 6a4bf369167aa3e6ab1860e2a748efe7eeae6eb4 > /data/local/tmp/sky.com.novenayvillancicos.santorosariocatolico.sha1
[ +33 ms] executing: /Users/leonardo/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell -x logcat -v time -t 1
[ +318 ms] --------- beginning of system
11-10 13:25:45.883 D/CompatibilityChangeReporter( 508): Compat change id reported: 143937733; UID 10102; state: ENABLED
[ +9 ms] executing: /Users/leonardo/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell am start -a android.intent.action.RUN -f 0x20000000 --ez enable-background-compilation true --ez enable-dart-profiling true --ez
enable-checked-mode true --ez verify-entry-points true com.novenayvillancicos.santorosariocatolico/com.novenayvillancicos.santorosariocatolico.MainActivity
[ +301 ms] Starting: Intent { act=android.intent.action.RUN flg=0x20000000 cmp=com.novenayvillancicos.santorosariocatolico/.MainActivity (has extras) }
[ ] Waiting for observatory port to be available...
[+3144 ms] Observatory URL on device: http://127.0.0.1:33313/DN2bSKCOYxE=/
[ ] executing: /Users/leonardo/Library/Android/sdk/platform-tools/adb -s emulator-5554 forward tcp:0 tcp:33313
[ +15 ms] 51881
[ ] Forwarded host port 51881 to device port 33313 for Observatory
[ +4 ms] Caching compiled dill
[ +47 ms] Connecting to service protocol: http://127.0.0.1:51881/DN2bSKCOYxE=/
[ +9 ms] W/FlutterActivityAndFragmentDelegate(19079): A splash screen was provided to Flutter, but this is deprecated. See flutter.dev/go/android-splash-migration for migration steps.
[ +364 ms] Launching a Dart Developer Service (DDS) instance at http://127.0.0.1:0, connecting to VM service at http://127.0.0.1:51881/DN2bSKCOYxE=/.
[ +211 ms] DDS is listening at http://127.0.0.1:51886/nJNYcB3Dt-8=/.
[ +52 ms] Successfully connected to service protocol: http://127.0.0.1:51881/DN2bSKCOYxE=/
[ +180 ms] DevFS: Creating new filesystem on the device (null)
[ +45 ms] DevFS: Created new filesystem on the device (file:///data/user/0/com.novenayvillancicos.santorosariocatolico/code_cache/santorosario_flutterCYKVCP/santorosario_flutter/)
[ +1 ms] Updating assets
[ +197 ms] Manifest contained wildcard assets. Inserting missing file into build graph to force rerun. for more information see #56466.
[ +7 ms] Syncing files to device sdk gphone x86...
[ +1 ms] <- reset
[ ] Compiling dart to kernel with 0 updated files
[ +5 ms] <- recompile package:santorosariocatolico/main.dart 838c752f-e9c7-4db8-94e4-a9af77ccb0a5
[ ] <- 838c752f-e9c7-4db8-94e4-a9af77ccb0a5
[ +204 ms] Updating files.
[ ] DevFS: Sync finished
[ ] Syncing files to device sdk gphone x86... (completed in 213ms)
[ ] Synced 0.0MB.
[ +2 ms] <- accept
[ +6 ms] Connected to _flutterView/0xf6a42c20.
[ +3 ms] Flutter run key commands.
[ +2 ms] r Hot reload. 🔥🔥🔥
[ ] R Hot restart.
[ ] h List all available interactive commands.
[ ] d Detach (terminate "flutter run" but leave application running).
[ ] c Clear the screen
[ ] q Quit (terminate the application on the device).
[ ] 💪 Running with sound null safety 💪
[ +1 ms] An Observatory debugger and profiler on sdk gphone x86 is available at: http://127.0.0.1:51886/nJNYcB3Dt-8=/
[ +77 ms] DevTools activation throttled until 2021-11-10 19:43:08.550687.
[ +255 ms] I/rosariocatolic(19079): Background concurrent copying GC freed 119636(6210KB) AllocSpace objects, 40(1612KB) LOS objects, 49% free, 5501KB/10MB, paused 1.393ms total 164.964ms
[ +38 ms] I/rosariocatolic(19079): The ClassLoaderContext is a special shared library.
[ +110 ms] I/chatty (19079): uid=10154(com.novenayvillancicos.santorosariocatolico) identical 1 line
[ ] I/rosariocatolic(19079): The ClassLoaderContext is a special shared library.
[ ] I/DynamiteModule(19079): Considering local module com.google.android.gms.ads.dynamite:0 and remote module com.google.android.gms.ads.dynamite:213806100
[ ] I/DynamiteModule(19079): Selected remote version of com.google.android.gms.ads.dynamite, version >= 213806100
[ +2 ms] D/DynamitePackage(19079): Instantiated singleton DynamitePackage.
[ +1 ms] D/DynamitePackage(19079): Instantiating com.google.android.gms.ads.ChimeraMobileAdsSettingManagerCreatorImpl
[ +92 ms] W/ConnectionStatusConfig(19079): Dynamic lookup for intent failed for action: com.google.android.gms.leibniz.events.service.START
[ ] W/GmsClient(19079): unable to connect to service: com.google.android.gms.leibniz.events.service.START on com.google.android.gms
[ +60 ms] I/WebViewFactory(19079): Loading com.google.android.webview version 83.0.4103.106 (code 410410681)
[ +2 ms] The Flutter DevTools debugger and profiler on sdk gphone x86 is available at: http://127.0.0.1:9101?uri=http://127.0.0.1:51886/nJNYcB3Dt-8=/
[ +1 ms] I/rosariocatolic(19079): The ClassLoaderContext is a special shared library.
[ ] D/nativeloader(19079): classloader namespace configured for unbundled product apk.
library_path=/product/app/WebViewGoogle/lib/x86:/product/app/WebViewGoogle/WebViewGoogle.apk!/lib/x86:/product/app/TrichromeLibrary/TrichromeLibrary.apk!/lib/x86:/product/lib:/system/product/lib
[ +23 ms] I/rosariocatolic(19079): The ClassLoaderContext is a special shared library.
[ ] D/nativeloader(19079): classloader namespace configured for unbundled product apk.
library_path=/product/app/WebViewGoogle/lib/x86:/product/app/WebViewGoogle/WebViewGoogle.apk!/lib/x86:/product/app/TrichromeLibrary/TrichromeLibrary.apk!/lib/x86:/product/lib:/system/product/lib
[ +73 ms] I/cr_LibraryLoader(19079): Loaded native library version number "83.0.4103.106"
[ ] I/cr_CachingUmaRecorder(19079): Flushed 3 samples from 3 histograms.
[ +266 ms] W/rosariocatolic(19079): Accessing hidden method Landroid/media/AudioManager;->getOutputLatency(I)I (greylist, reflection, allowed)
[ +9 ms] W/cr_media(19079): Requires BLUETOOTH permission
[ +5 ms] D/HostConnection(19079): HostConnection::get() New Host Connection established 0xf6a26730, tid 19424
[ +46 ms] D/HostConnection(19079): HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1
ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV_Cache ANDROID_EMU_async_unmap_buffer ANDROID_EMU_has_shared_slots_host_memory_allocator ANDROID_EMU_sync_buffer_data ANDROID_EMU_read_color_buffer_dma GL_OES_EGL_image_external_essl3
GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_async_frame_commands ANDROID_EMU_gles_max_version_3_0
[ +4 ms] D/EGL_emulation(19079): eglCreateContext: 0xf6a16510: maj 3 min 0 rcv 3
[ +3 ms] D/EGL_emulation(19079): eglMakeCurrent: 0xf6a16510: ver 3 0 (tinfo 0xc1aa9f70) (first time)
[ +3 ms] I/rosariocatolic(19079): Waiting for a blocking GC ProfileSaver
[ +200 ms] I/VideoCapabilities(19079): Unsupported profile 4 for video/mp4v-es
[ ] W/cr_MediaCodecUtil(19079): HW encoder for video/avc is not available on this device.
[ +19 ms] D/EGL_emulation(19079): eglCreateContext: 0xf6a283a0: maj 3 min 0 rcv 3
[✓] Flutter (Channel stable, 2.5.3, on macOS 12.0.1 21A559 darwin-x64, locale es-419)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0-rc4)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] VS Code (version 1.62.1)
[✓] Connected device (4 available)
• No issues found!
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 17
- Comments: 36 (1 by maintainers)
We’re having the same issue. It seems that underlying
MobileAds#initializeinvocation never returns async result.The issue happens on Android devices and emulators, builds for iOS do not have this problem.
same issue
E/AndroidRuntime(17716): FATAL EXCEPTION: main E/AndroidRuntime(17716): java.lang.LinkageError: Method java.lang.Object com.google.android.gms.internal.ads.jo3.zzb() overrides final method in class Lcom/google/android/gms/internal/ads/bo3; (declaration of ‘com.google.android.gms.internal.ads.jo3’ appears in base.apk) E/AndroidRuntime(17716): at com.google.android.gms.internal.ads.ev0.<init>(Unknown Source:307) E/AndroidRuntime(17716): at com.google.android.gms.internal.ads.dv0.zza(Unknown Source:66) E/AndroidRuntime(17716): at com.google.android.gms.internal.ads.kk2.a(Unknown Source:297) E/AndroidRuntime(17716): at com.google.android.gms.internal.ads.e82.l0(Unknown Source:75) E/AndroidRuntime(17716): at com.google.android.gms.internal.ads.e82.Q2(Unknown Source:5) E/AndroidRuntime(17716): at com.google.android.gms.internal.ads.a70.i(Unknown Source:28) E/AndroidRuntime(17716): at com.google.android.gms.ads.c0.a.b(Unknown Source:29) E/AndroidRuntime(17716): at io.flutter.plugins.googlemobileads.FlutterAdLoader.loadInterstitial(Unknown Source:2) E/AndroidRuntime(17716): at io.flutter.plugins.googlemobileads.FlutterInterstitialAd.load(Unknown Source:23) E/AndroidRuntime(17716): at io.flutter.plugins.googlemobileads.GoogleMobileAdsPlugin.onMethodCall(Unknown Source:1365) E/AndroidRuntime(17716): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(Unknown Source:17) E/AndroidRuntime(17716): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(Unknown Source:49) E/AndroidRuntime(17716): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(Unknown Source:4) E/AndroidRuntime(17716): at android.os.MessageQueue.nativePollOnce(Native Method) E/AndroidRuntime(17716): at android.os.MessageQueue.next(MessageQueue.java:335) E/AndroidRuntime(17716): at android.os.Looper.loop(Looper.java:190) E/AndroidRuntime(17716): at android.app.ActivityThread.main(ActivityThread.java:8052) E/AndroidRuntime(17716): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(17716): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656) E/AndroidRuntime(17716): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967)
We have confirmed that this is related to a serving change and only affects a subset of app ids. A fix is being worked on which will roll out without needing to update the plugin or SDK version.
For the future, I would not recommend blocking your app’s startup on
MobileAds.instance.initialize().why the official google_mobile_ads plugin is so bad???
Also quote from documentation:
It’s not true, there isn’t timeout, the app freezes completely
This issue has rendered my production app useless for thousands of users. It was all working fine for months 😢
This issue also causing problem to my production app. App was fine until now. Yesterday got a bad review that app is not event opening. After debugging found that
MobileAds.instance.initialize()never completes. I didn’t change anything (same version of my app was working before) that would affect it. It seems to be issue from Google AdMob.Workaround is to not await for for
MobileAds.instance.initialize().And a interesting part is that, it does not happen in all device, it don’t return any value in Emulator and my mobile POCO F1 (Pixel Experience). But worked fine in POCO X3 (MIUI).
Using
google_mobile_ads: ^0.13.3Also happening with me. In my tests I found this:
com.google.android.gms.ads.MobileAds.Hi @maheshmnj, I have replace my main code with your code and happens the same problem on my projects. I had recorded a video for you. https://www.youtube.com/watch?v=G-eCZGUlSlk
Hi there, upon further investigation, we can confirm the ads serving issue mentioned in this thread is now resolved. Meanwhile, we want to call out that Awaiting init in main function is an antipattern. Init involves a network call, which is async and may fail. We recommend you avoid using this approach in the code. Thank you.
I tried again with the simplest code sample and yet did not reproduce any issue the ad loads 100% of the time for me. Keeping this issue open for further investigation from the team.
code sample
flutter doctor -v
cc: @jjliu15
As other people said, this problem happens only on android devices. In some cases, first time works but other runs fails. I had an app on the store for months with that line working without problems but yesterday we realize that all of our apps with that line get stuck on splash screen.
Same 🥺
Hi guys I am also receiving this problem before upgrading to google_mobiles_ads my app in google play was working fine on all devices using the flutter admob, it was even working on my test app, then my android app stop loading, anyone with the old version of my app could load the app and the Ads work fine and anyone who has updated to new version the apps crashes iOS is fine
I get the same issue as everyone, my android app will not load at all unless I change my Application ID to any random ID or I remove Await from MobileAds.instance.initialize() however the ADs will still not load and error message No Ad Config even with test ad ID’s,
I can replicate the issue on any app that is using google_mobile_ads just by adding my application ID or any live application ID.
version ^0.13.4 & ^0.13.6 SDK 30 Error message: No Ad config
I think this issue has popped up around the same time for everyone, I had this for a few days not but just saw this tread
Any help would be great thanks
This issue ruined the ratings of my app of million+ downloads, had to remove the “await” as a temporary fix in new update. Ads are not working now.
Error persist on google_mobile_ads: ^1.0.0
The same problem my app crashed all instances. I had to update.
It only initialize with test app id