dd-sdk-android
dd-sdk-android copied to clipboard
Crash on Datadog v2.0.0 on DdRumContentProvider: java.lang.ClassNotFoundException
Hello,
Since the migration to Datadog v2.0.0 on Android, we're facing a new crash happening on devices on Android 10.
Stack Trace:
Fatal Exception: java.lang.RuntimeException: Unable to get provider com.datadog.android.rum.DdRumContentProvider: java.lang.ClassNotFoundException: Didn't find class "com.datadog.android.rum.DdRumContentProvider" on path: DexPathList[[zip file "/data/app/fr.vestiairecollective-BBCXsWSSAdVcXE74IfAxdg==/base.apk"],nativeLibraryDirectories=[/data/app/fr.vestiairecollective-BBCXsWSSAdVcXE74IfAxdg==/lib/arm64, /data/app/fr.vestiairecollective-BBCXsWSSAdVcXE74IfAxdg==/base.apk!/lib/arm64-v8a, /system/lib64, /system/product/lib64]]
at android.app.ActivityThread.installProvider(ActivityThread.java:7029)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6569)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6486)
at android.app.ActivityThread.access$1400(ActivityThread.java:227)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1888)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7399)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:502)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:980)
Do you know how can we fix this?
Thank you
hi @RamiTrabelsi - we'll look into this asap. Do you have any additional details that might help in debugging this crash (for example, do you know whether these are these upgraded or fresh installations? does this issue seem to occur only on specific device types? does it affect all or only some Android 10?)
Hello,
Thanks for the reactivity. We don't have the info about if the devices having the crash, are upgraded or fresh installations. We know it's 100% Android 10 and the crash is happening in the background (it seems happening on app startup).
Since the crash was growing, we decided to revert to the old version on 1.x.x.
Hello @RamiTrabelsi. Can you please open your apk file in Android Studio (Build -> Analyze APK) and check if com.datadog.android.rum.DdRumContentProvider is presented in any of dex files you have inside the APK?
Hello, yes I can find the class on both debug and release apks.
@RamiTrabelsi Thanks for the quick return. Do you see this crash only on Android 10? If you run the app on say Android 11, does it crash with SDK v2?
Can you also share AGP version you are using?
I see that this class is not in a primary DEX file, can you try to follow the docs here to push this file to the primary DEX file and see if it helps?
Thanks for the quick reply. On our latest release version, we have today 9 crash events impacting 8 users. 8 of them are on Android 10, and 1 appeared today on Android 9.
Our actual AGP version is 7.4.2.
Okay, I'll try to add to our proguard file to keep that class:
-keep class com.datadog.android.rum.DdRumContentProvider
Thanks for your help!
Hello @RamiTrabelsi! Do you have any update on this issue? Did the proposed solution help you?
Hey mates
@RamiTrabelsi is off today. I'll try to test it today. Otherwise, we'll bring news next week.
Thanks!
Hello @0xnm, so it seems to work as I could push that class to primary DEX. But since we were blocked by this issue to push this change to production, we couldn't yet 100% confirm that it's resolved as the new version is not yet pushed to production (we reverted) so for now we can't see if previously affected devices by the crash, don't have it anymore.
Maybe we can close this thread, and if we see that the problem is still there (rare chances) we can re-open the issue.
Thank you very much for the help 🙏
Hello @0xnm, it seems that the crash is back again. I made sure that the class DdRumContentProvider is available on the primary DEX (you can see the screenshot attached). What is noticeable is that this crash is happening 100% on devices with OS Android 10. This crash appeared 2 times when we tried to push the latest Datadog version (2.0 then 2.2) to prod.
Stacktrace:
Fatal Exception: java.lang.RuntimeException: Unable to get provider com.datadog.android.rum.DdRumContentProvider: java.lang.ClassNotFoundException: Didn't find class "com.datadog.android.rum.DdRumContentProvider" on path: DexPathList[[zip file "/data/app/fr.vestiairecollective-NWkZllpKxpWq-Kxgfp8jCw==/base.apk"],nativeLibraryDirectories=[/data/app/fr.vestiairecollective-NWkZllpKxpWq-Kxgfp8jCw==/lib/arm64, /data/app/fr.vestiairecollective-NWkZllpKxpWq-Kxgfp8jCw==/base.apk!/lib/arm64-v8a, /system/lib64, /product/lib64]]
at android.app.ActivityThread.installProvider(ActivityThread.java:7756)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:7296)
at android.app.ActivityThread.handleMakeApplication(ActivityThread.java:7153)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7121)
at android.app.ActivityThread.access$1600(ActivityThread.java:274)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2102)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:8154)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
Thanks for your help !
Hello @RamiTrabelsi! This is a quite strange issue, indeed. I managed to find a similar issue for androidx.startup library mentioned here, it also happens only on Android 10 devices, maybe that thread can be helpful for you (and maybe here some more useful information can be found).
Can you give us a bit more information based on the discussions in the threads I linked:
- Is your application multi-process?
- Does this happen if you migrate to AGP 8.x? I know it can be a big change for you, just curious if you already tried.
Hello @RamiTrabelsi! I'm closing this ticket due to inactivity. Please don't hesitate to re-open it if needed.
Hi,
I would like the issue to be reopened as we are facing the exact same crash, only happening on some Android 10 devices in our production app.
I couldn't reproduce the issue on my Android 10 test device, so any proposed fix will have to be sent to production to be validated.
To answer the questions you asked above:
Does this happen if you migrate to AGP 8.x?
We are on AGP 8.3.2
Is your application multi-process?
It is not
We didn't try the Proguard rule solution proposed above, this is one of the fix we're planning to try even if it doesn't seem to have worked for @RamiTrabelsi.
Is there anything we can try, or information we can provide to help fix this issue?
Repoened based on @NFesquet feedback in #2139
Hi @NFesquet ,
Are you publishing your application via an APK or App Bundle ? If you rename the *.apk/ *.aab and look for the classes.dex file with the dex2jar tool, to check for the presence of the com.datadog.android.rum.DdRumContentProvider
Also, can you try making sure that all the Datadog libraries you're using are using the same version in your app?
Thanks for reopening the issue.
Are you publishing your application via an APK or App Bundle ?
Both, depending on the targeted country. In the country we see the most crashes, the app is distributed via apk. But there are occurrences in countries where app is distributed via aab.
If you rename the
*.apk/*.aaband look for theclasses.dexfile with the dex2jar tool, to check for the presence of thecom.datadog.android.rum.DdRumContentProvider
Tried it on apk, DdRumContentProvider is not in classes.dex but can be found in classes3.dex. I'll add the proguard rule to push it to the primary DEX and let you know the result when next release is in production.
Also, can you try making sure that all the Datadog libraries you're using are using the same version in your app?
Confirmed, all lib versions (logs, http, rum and trace) are centralised in a single value, 2.10.0 currently.
Yes so it's indeed the class not being kept in the primary DEX, let me know how the proguard rule works.
Hey ! Just wanted to let you know that the crash is unfortunately still present even after adding the proguard rule 😞 (@NFesquet also upgraded to the 2.11.0 version for all Datadog libraries)
Hello @WessimBetclic!
Can you please confirm that after adding a Proguard rule com.datadog.android.rum.DdRumContentProvider can now be found in classes.dex (not in classes<X>.dex), but crash still occurs?
Hi @0xnm,
For a reason I cannot explain, the Proguard rule does not put DdRumContentProvider in primary DEX.
I tried
- Adding
-keep class com.datadog.android.rum.DdRumContentProviderin proguard-rules.pro - Adding
-keep class com.datadog.android.rum.DdRumContentProviderin a newly created multidex-config.pro and apply it as stated in official documentation
android {
buildTypes {
getByName("release") {
multiDexKeepProguard = file("multidex-config.pro")
...
}
}
}
I also tried both at the same time. Every solution will put file in either classes3.dex or classes4.dex.
Hi @0xnm,
I opened an issue in Google tracker and according to them:
multiDexKeepProguardwon't work ifminSdk >= 21(that's my case)- it doesn't matter what dex files contains the file https://issuetracker.google.com/issues/363903530#comment4
Updating the Proguard rule to keep class didn't work, so I'm a little short of ideas right now.
@NFesquet Honestly it looks like as unfortunate issue of the particular Android version itself, I doubt we can do anything on our side.
Can you try to use the newer SDK versions? Maybe AGP will re-arrange classes and issue will be gone.
This issue has been automatically marked as stale because it has not had recent activity and has the awaiting-response label.
It will be closed if no further activity occurs within 3 days.