dd-sdk-android icon indicating copy to clipboard operation
dd-sdk-android copied to clipboard

Crash on Datadog v2.0.0 on DdRumContentProvider: java.lang.ClassNotFoundException

Open RamiTrabelsi opened this issue 2 years ago • 22 comments
trafficstars

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

RamiTrabelsi avatar Aug 22 '23 16:08 RamiTrabelsi

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?)

jonathanmos avatar Aug 23 '23 07:08 jonathanmos

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.

RamiTrabelsi avatar Aug 24 '23 08:08 RamiTrabelsi

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?

0xnm avatar Aug 24 '23 09:08 0xnm

Hello, yes I can find the class on both debug and release apks.

image image

RamiTrabelsi avatar Aug 25 '23 09:08 RamiTrabelsi

@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?

0xnm avatar Aug 25 '23 09:08 0xnm

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!

RamiTrabelsi avatar Aug 25 '23 13:08 RamiTrabelsi

Hello @RamiTrabelsi! Do you have any update on this issue? Did the proposed solution help you?

0xnm avatar Sep 15 '23 08:09 0xnm

Hey mates

@RamiTrabelsi is off today. I'll try to test it today. Otherwise, we'll bring news next week.

Thanks!

orafaaraujo avatar Sep 15 '23 14:09 orafaaraujo

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 🙏

RamiTrabelsi avatar Sep 21 '23 12:09 RamiTrabelsi

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)
image

Thanks for your help !

RamiTrabelsi avatar Oct 20 '23 09:10 RamiTrabelsi

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.

0xnm avatar Oct 20 '23 14:10 0xnm

Hello @RamiTrabelsi! I'm closing this ticket due to inactivity. Please don't hesitate to re-open it if needed.

0xnm avatar Jan 15 '24 14:01 0xnm

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?

NFesquet avatar Jul 19 '24 09:07 NFesquet

Repoened based on @NFesquet feedback in #2139

xgouchet avatar Jul 24 '24 09:07 xgouchet

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?

xgouchet avatar Jul 24 '24 11:07 xgouchet

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/ *.aab and look for the classes.dex file with the dex2jar tool, to check for the presence of the com.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.

NFesquet avatar Jul 25 '24 07:07 NFesquet

Yes so it's indeed the class not being kept in the primary DEX, let me know how the proguard rule works.

xgouchet avatar Jul 25 '24 08:07 xgouchet

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)

WessimBetclic avatar Aug 06 '24 11:08 WessimBetclic

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?

0xnm avatar Aug 14 '24 08:08 0xnm

Hi @0xnm,

For a reason I cannot explain, the Proguard rule does not put DdRumContentProvider in primary DEX. I tried

  1. Adding -keep class com.datadog.android.rum.DdRumContentProvider in proguard-rules.pro
  2. Adding -keep class com.datadog.android.rum.DdRumContentProvider in 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.

NFesquet avatar Aug 19 '24 13:08 NFesquet

Hi @0xnm,

I opened an issue in Google tracker and according to them:

  • multiDexKeepProguard won't work if minSdk >= 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 avatar Sep 06 '24 09:09 NFesquet

@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.

0xnm avatar Sep 09 '24 07:09 0xnm

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.

github-actions[bot] avatar Oct 07 '25 07:10 github-actions[bot]