Skip to content

fix(android): preserve wind JNI callbacks - #639

Merged
whes1015 merged 1 commit into
mainfrom
fix/android-wind-jni-r8
Oct 22, 2026
Merged

whes1015 merged 1 commit into
mainfrom
fix/android-wind-jni-r8

Conversation

@bamboo0403

@bamboo0403 bamboo0403 commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

修正 Android release 版使用 R8 混淆後,WindParticleLayer 的 JNI callback 被重新命名,導致開啟 ECMWF/GFS 風場圖層時發生 NoSuchMethodError 並造成 App 閃退。

  • 新增 android/app/proguard-rules.pro
  • 保留 WindParticleLayer 由 C++ 呼叫的四個 JNI callback:
    • onNativeInitialize
    • onNativeRender
    • onNativeContextLost
    • onNativeDeinitialize
  • 在 Android release build 套用該 ProGuard/R8 規則

相關 issue

沒有對應的 issue。

怎麼驗

  • 使用 Play 商店 26w43a 重現並取得 crash log
  • 確認錯誤為 R8 混淆造成的 NoSuchMethodError
  • flutter run Android ARM64 實機測試正常
  • 已使用修正後的 release APK 在實機重新驗證
  • 尚未重新發布 Play 測試版本

檢查清單

  • tool/check/commits.sh origin/main..HEAD 通過
    —— commit 訊息就是更新日誌,格式見 commit.md
  • 一個 commit 一件事(這條 gate 驗不了,靠自己和 review)
  • mise exec -- flutter analyze 與 mise exec -- flutter test 通過
  • 新的使用者可見字串都走 AppLocalizations,沒有寫死
  • CI 全部通過(gh pr checks:每一項都是 pass 或 skipped)—— 沒過不能合併,
    見 pr.md
  • 有 UI 變更的話:用的是 AppSpacing / AppRadius / AppMotion,
    深色模式看過,文字對比度可接受

@bamboo0403
bamboo0403 added this pull request to stack #640 October 21, 2026 00:42
@bamboo0403
bamboo0403 force-pushed the fix/windows-mise-path-check branch 4 times, most recently from 3f7d754 to 06fc721 Compare October 21, 2026 04:01
@lowrt
lowrt force-pushed the fix/windows-mise-path-check branch from 06fc721 to 32456bc Compare October 21, 2026 04:36
@bamboo0403
bamboo0403 force-pushed the fix/android-wind-jni-r8 branch from 1983a54 to 8b2b4ef Compare October 21, 2026 04:39
@codecov

codecov Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.49%. Comparing base (565bad4) to head (2838141).

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lowrt lowrt added this to the v26.4 milestone Oct 21, 2026
@lowrt
lowrt force-pushed the fix/windows-mise-path-check branch 3 times, most recently from 20b077e to f415e79 Compare October 21, 2026 22:20
Platform: android

Fix(zh-Hant): 修正 Android 正式版開啟風場圖層時閃退
Fix(en-US): stop Android release builds crashing when wind layers open
@whes1015
whes1015 force-pushed the fix/android-wind-jni-r8 branch from 8b2b4ef to 2838141 Compare October 21, 2026 23:54
@github-actions

Copy link
Copy Markdown

✅ OpenCodeReview: Review skipped: no items were selected.

@whes1015
whes1015 removed this pull request from stack #640 October 21, 2026 23:56
@whes1015
whes1015 changed the base branch from fix/windows-mise-path-check to main October 21, 2026 23:56
@whes1015

Copy link
Copy Markdown
Member

維護者調整:這個修正改成直接以 main 為 base,和 #638 拆開,讓閃退修正可以先合併。

做了什麼

  • 解除和 ci: make local checks portable across platforms #638 的 stack,force-push 這個分支,只留 fix(android): preserve wind JNI callbacks 一個 commit(作者仍是你)。
  • 原本夾在這裡的 ci: run full checks on Windows 移到 ci: make local checks portable across platforms #638,Windows 的工具改動在那邊一起處理。
  • 拿掉 android/app/build.gradle.kts 的兩處改動:Flutter 的 Gradle plugin 在 release 已經會開 R8,而且 android/app/proguard-rules.pro 存在就會自動加進去(FlutterPlugin.kt),所以只要這個檔案就夠了。檔案開頭補了註解,說明為什麼需要這條規則、以及為什麼不用改 Gradle。

驗證(release APK,用 dexdump 看 WindParticleLayer 的方法名稱)

版本 保留下來的 JNI 名稱
main 只有 nativeCreateHost,四個 onNative* 都不見了,也就是這次閃退的原因
main 加上 proguard-rules.pro(沒改 Gradle) nativeCreateHost、onNativeInitialize、onNativeRender、onNativeContextLost、onNativeDeinitialize
這個分支現在的版本 同上,五個都在

push 前 tool/commit.sh --push 全部通過。之後如果在 fork 的 wind_particle_host.cpp 新增 GetMethodID,這裡也要跟著加。

@whes1015
whes1015 merged commit 27faca6 into main Oct 22, 2026
8 checks passed
@whes1015
whes1015 deleted the fix/android-wind-jni-r8 branch October 22, 2026 00:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants