sentry-react-native
sentry-react-native copied to clipboard
Reducing library size (specially on Android)
Hey! I've convinced my team/company to use Sentry to track our errors. However there is one small problem, we are very conservative when it comes to increasing the size of our app (specially on Android), after adding Sentry our .apk size increased from 43.90mb to 45.40mb. This makes it a hard pill to swallow for us, so I have a couple of questions.
- Is there any possible way to reduce the bundle size with the library as is?
- Are there any plans/ongoing work to reduce the size of the library further down?
Many thanks!
Just a quick update, after checking the documentation on the android sentry library, a suggestion is to change from the sentry-android dependency to sentry-android-core which drops support for the NDK (means collecting C/C++ stack traces is no longer possible), this seems like it reduces the final apk size (waiting for the final build from my CI to confirm this).
I used patch-package to change the dependency in this library's build.gradle
and seems like everything compiles/works just fine.
@ospfranco Yes you should be able to disable the NDK just fine by using the sentry-android-core
package. We have also discussed monitoring the package size and considering ways to reduce it, cc @bruno-garcia will have better insight on this.
Going with sentry-android-core
only is a good options. It's pure Java 1.8 so no Kotlin std overhead or native code.
Right now that's what we can offer to trim down an Android app. We want to explore more things in the future though.
maybe we could document how to use sentry-android-core
only at least
we believe that the NDK support should be ootb and people that don't want to pay for it due to bundle size, they can use the sentry-android-core SDK, we'll document this on the RN docs.
@ospfranco would you like to give it a try on https://microsoft.github.io/rnx-kit/docs/guides/bundling#tree-shaking ?
Sorry, no longer at the same company, so this is a non-issue for me, but I've been hearing all over twitter that tree-shaking does help :)
As there are workarounds (using sentry-android-code and tree-shaking) you can close this issue if you want to
Thanks for the feedback.