Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
RamiTrabelsi opened this issue Aug 22, 2023 · 22 comments
Labels
bug Something isn't working

Comments

@RamiTrabelsi
Copy link

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 RamiTrabelsi added the bug Something isn't working label Aug 22, 2023
@jonathanmos
Copy link
Contributor

jonathanmos commented Aug 23, 2023

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

@RamiTrabelsi
Copy link
Author

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.

@0xnm
Copy link
Contributor

0xnm commented Aug 24, 2023

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?

@RamiTrabelsi
Copy link
Author

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

image image

@0xnm
Copy link
Contributor

0xnm commented Aug 25, 2023

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

@RamiTrabelsi
Copy link
Author

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!

@0xnm
Copy link
Contributor

0xnm commented Sep 15, 2023

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

@orafaaraujo
Copy link

Hey mates

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

Thanks!

@RamiTrabelsi
Copy link
Author

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
Copy link
Author

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 !

@0xnm
Copy link
Contributor

0xnm commented Oct 20, 2023

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
Copy link
Contributor

0xnm commented Jan 15, 2024

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

@0xnm 0xnm closed this as completed Jan 15, 2024
@NFesquet
Copy link

NFesquet commented Jul 19, 2024

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?

@xgouchet
Copy link
Collaborator

Repoened based on @NFesquet feedback in #2139

@xgouchet xgouchet reopened this Jul 24, 2024
@xgouchet
Copy link
Collaborator

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?

@NFesquet
Copy link

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.

@xgouchet
Copy link
Collaborator

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

@WessimBetclic
Copy link

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)

@0xnm
Copy link
Contributor

0xnm commented Aug 14, 2024

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?

@NFesquet
Copy link

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
Copy link

NFesquet commented Sep 6, 2024

Hi @0xnm,

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

Updating the Proguard rule to keep class didn't work, so I'm a little short of ideas right now.

@0xnm
Copy link
Contributor

0xnm commented Sep 9, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants