Skip to content

Add DT_HASH to native library for Android 5.x compatibility#2028

Merged
WhiredPlanck merged 4 commits into
developfrom
copilot/fix-android-5-1-crash
Jun 16, 2026
Merged

Add DT_HASH to native library for Android 5.x compatibility#2028
WhiredPlanck merged 4 commits into
developfrom
copilot/fix-android-5-1-crash

Conversation

Copilot AI commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Android 5.1 devices fail to launch the app because librime_jni.so is built with GNU hash only, which older Android dynamic linkers cannot load. The Java crash during MainActivity startup is a downstream effect of System.loadLibrary("rime_jni") failing in native library loading.

  • Root cause

    • librime_jni.so was linked with --hash-style=gnu
    • Android 5.x expects the legacy SysV DT_HASH section; with only DT_GNU_HASH, dlopen() fails with empty/missing DT_HASH
  • Change

    • Update the native linker flags in app/src/main/jni/CMakeLists.txt
    • Switch from GNU-only hash output to dual hash output so the shared library contains both DT_HASH and DT_GNU_HASH
  • Effect

    • Restores compatibility with Android 5.x loaders
    • Preserves behavior on newer Android versions
-add_link_options("LINKER:--hash-style=gnu,--build-id=none")
+add_link_options("LINKER:--hash-style=both,--build-id=none")

Copilot AI changed the title [WIP] Fix application crash on Android 5.1 fix: add DT_HASH for Android 5.x (API ≤22) compatibility Jun 16, 2026
Copilot AI requested a review from WhiredPlanck June 16, 2026 15:28
Copilot AI changed the title fix: add DT_HASH for Android 5.x (API ≤22) compatibility Defer Rime session startup from MainViewModel initialization Jun 16, 2026
Copilot AI changed the title Defer Rime session startup from MainViewModel initialization Add DT_HASH to native library for Android 5.x compatibility Jun 16, 2026
@WhiredPlanck WhiredPlanck linked an issue Jun 16, 2026 that may be closed by this pull request
@WhiredPlanck WhiredPlanck marked this pull request as ready for review June 16, 2026 16:57
@WhiredPlanck WhiredPlanck merged commit aefab1d into develop Jun 16, 2026
8 checks passed
@WhiredPlanck WhiredPlanck deleted the copilot/fix-android-5-1-crash branch June 16, 2026 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android 5.1 无法使用

2 participants