Skip to content

Android libsentry.so takes 209KB after compression: Can it be smaller? #700

Closed

Description

@fzyzcjy

Platform:

  • Android -> If yes, which Device API (and compileSdkVersion/targetSdkVersion/Build tools) version?
  • Java -> If yes, which Java (and sourceCompatibility/targetCompatibility) version?
  • Kotlin -> If yes, which Kotlin (and jvmTarget) version?
  • NDK -> If yes, which NDK/CMake version?
  • React-Native -> If yes, which version?
  • Timber -> If yes, which version?
  • Log4j2 -> If yes, which version?
  • Logback -> If yes, which version?
  • Spring -> If yes, which version?

IDE:

  • Android Studio -> If yes, which version?
  • IntelliJ -> If yes, which version?
  • Other -> If yes, which one?

Build system:

  • Gradle -> If yes, which version?
  • Buck -> If yes, which version?
  • Bazel -> If yes, which version?
  • Maven -> If yes, which version?
  • Other -> If yes, which one?

Android Gradle Plugin:

  • Yes -> If yes, which version?
  • No

Sentry Android Gradle Plugin:

  • Yes -> If yes, which version?
  • No

Proguard/R8:

  • Enabled
  • Disabled

Platform installed with:

  • JCenter
  • Bintray
  • Maven Central
  • Manually

The version of the SDK:
latest


I have the following issue:

When looking at my output apk, I see libsentry.so takes 209KB after compression. Can it be smaller? Thank you!

image

Steps to reproduce:

  • just compile it

Actual result:

  • big

Expected result:

  • small

Activity

  1. bruno-garcia commented on Jul 26, 2021

    @bruno-garcia
    Member

    You have the option of not tracking native crashes by installing sentry-android-core instead of sentry-android. That is because sentry-android brings in sentry-android-ndk which includes native libraries such as libsentry.so.

    If that works for you, docs about how to do that are here: https://docs.sentry.io/platforms/android/using-ndk/#using-the-sdk-without-the-ndk

    You wouldn't capture crashes from native libraries though.

    /cc @getsentry/owners-native

  2. fzyzcjy commented on Jul 27, 2021

    @fzyzcjy
    Author

    @bruno-garcia I have some c++ code so I need to capture the native crashes :/ is there any ways to shrink it?

  3. marandaneto commented on Aug 17, 2021

    @marandaneto
    Contributor

    @fzyzcjy currently not, but you can pre-compile your own version of https://github.com/getsentry/sentry-native and remove features that are not used by your project.

  4. fzyzcjy commented on Aug 17, 2021

    @fzyzcjy
    Author

    @marandaneto Thank you.

  5. Swatinem commented on Aug 17, 2021

    @Swatinem
    Contributor

    its possible that some of the codesize comes from us vendoring a libunwindstack fork, which is heavy on c++, which is not known for small code size.

    Anyhow, it is currently needed, otherwise you won’t have any stack traces. But we are looking into ways to improve that in the future.

  6. fzyzcjy commented on Aug 17, 2021

    @fzyzcjy
    Author

    @Swatinem Thank you as well.

  7. marandaneto commented on Apr 13, 2022

    @marandaneto
    Contributor

    @Swatinem can we transfer this issue to sentry-native since the Native bits live there? https://github.com/getsentry/sentry-native/tree/3436a29d839aa7437548be940ab62a85ca699635

  8. Swatinem commented on Apr 13, 2022

    @Swatinem
    Contributor

    Sure, though I doubt there is any actionable thing we can do about code size right now. Unless we drop our custom fork of libunwindstack and rely on the system library, which only exists on fairly recent Android versions.

  9. 11 remaining items

  10. jpnurmi commented on Nov 5, 2026

    @jpnurmi
    Collaborator

    The upcoming sentry-java 9 removes libsentry.so from apps by default, so they no longer pay its size cost: sentry-android no longer depends on sentry-android-ndk in the 9.x.x branch:

    Native crashes will be reported through tombstones on Android 12+ instead. Apps that need native crash reporting on older Android versions, or the NDK APIs, can still add io.sentry:sentry-android-ndk explicitly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions