ANR Issue on MobileAds.initialize() in Android Application
I am facing ANR (Application Not Responding) issues in my Android application related to the initialization of the Mobile Ads SDK. I have a class named GoogleAdsManager where I perform the initialization in the initAds() function, and this function is called in the onCreate() method of the main Application class.
Here is a simplified version of my code:
class GoogleAdsManager { fun initAds(context: Context) { // Other initialization tasks MobileAds.initialize(context) } }
And in my Application class:
class MyApplication : Application() { override fun onCreate() { super.onCreate() val googleAdsManager = GoogleAdsManager() googleAdsManager.initAds(this) } }
The issue is that I am receiving ANR reports on various devices, but I am unable to reproduce it on my own device. Firebase Crashlytics reports indicate that this ANR occurs more frequently than usual.
I suspect that the MobileAds.initialize(context) call might be the culprit. However, since I cannot reproduce the issue locally, I am seeking advice on how to investigate and resolve ANR issues related to the Mobile Ads SDK initialization.
Has anyone experienced similar ANR issues with MobileAds.initialize()? Are there specific scenarios or devices where such ANRs are more likely to occur? Are there alternative approaches or best practices for initializing Mobile Ads SDK to avoid ANR issues? Any insights or suggestions on how to address this ANR issue would be greatly appreciated. Thank you!
Seems this is a known issue and Google is working on a fix. Have you tried these optimizations https://developers.google.com/admob/android/optimize-initialization?
While I have implemented various optimizations, the application continues to experience ANR (Application Not Responding) issues despite these efforts. Regrettably, I have not yet identified a definitive solution to mitigate the ANR in my application.
@AneesAhmad could you find a solution to this issue? My app also works fine for some phones but gets anr for others.
@nazgulll still facing the same issue. Unable to find any solution yet.