From 9074b5d1d7e54f4d6a0370102981ea4f317dedc0 Mon Sep 17 00:00:00 2001 From: KIMI Date: Sat, 15 Aug 2026 16:38:33 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20release=20=E5=8C=85?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E7=BB=84=E4=BB=B6=E6=B0=B8=E4=B9=85=E6=97=A0?= =?UTF-8?q?=E5=93=8D=E5=BA=94=EF=BC=88B-58=20=E7=94=A8=E6=88=B7=E6=89=8B?= =?UTF-8?q?=E6=9C=BA=E7=99=BB=E5=BD=95=E5=8D=A1=E6=AD=BB=E7=9A=84=E6=A0=B9?= =?UTF-8?q?=E5=9B=A0=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因两条,叠加导致 release 包 initSDK 永不返回: 1. AGP 9 默认开启 R8 混淆,OpenIM 插件用反射按字段名分发方法 (getDeclaredField("imManager")),混淆后抛 NoSuchFieldException 被静默吞掉, Dart 侧 Future 永远 pending —— 表现为「消息组件初始化超时」 2. 插件 manifest 漏声明 ACCESS_NETWORK_STATE,onAttachedToEngine 里 registerDefaultNetworkCallback 抛 SecurityException,注册中断 修复: - release 关闭 isMinifyEnabled / isShrinkResources(与官方样板工程配置一致) - App manifest 补 ACCESS_NETWORK_STATE 已在模拟器上用同版本 SDK 最小复现 App 验证:修复前 release 必现卡死, 修复后 initSDK 返回 true、connect SUCCESS、login 成功。debug 包之前正常 (debug 不混淆),与此结论一致。版本号 1.0.5+6 --- mobile/android/app/build.gradle.kts | 5 +++++ mobile/android/app/src/main/AndroidManifest.xml | 3 +++ mobile/pubspec.yaml | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/mobile/android/app/build.gradle.kts b/mobile/android/app/build.gradle.kts index 30ecc42..e4384db 100644 --- a/mobile/android/app/build.gradle.kts +++ b/mobile/android/app/build.gradle.kts @@ -35,6 +35,11 @@ android { buildTypes { release { + // OpenIM 插件靠反射按字段名分发方法调用,R8/混淆会把字段改名导致 + // 所有 SDK 调用静默无响应(表现为 initSDK 永久不返回)。 + // 与官方样板工程一致:release 关闭混淆和资源压缩。 + isMinifyEnabled = false + isShrinkResources = false // TODO: Add your own signing config for the release build. // Signing with the debug keys for now, so `flutter run --release` works. signingConfig = signingConfigs.getByName("debug") diff --git a/mobile/android/app/src/main/AndroidManifest.xml b/mobile/android/app/src/main/AndroidManifest.xml index e36a9d7..77186a8 100644 --- a/mobile/android/app/src/main/AndroidManifest.xml +++ b/mobile/android/app/src/main/AndroidManifest.xml @@ -1,6 +1,9 @@ + + diff --git a/mobile/pubspec.yaml b/mobile/pubspec.yaml index d92f459..c2cd67c 100644 --- a/mobile/pubspec.yaml +++ b/mobile/pubspec.yaml @@ -1,7 +1,7 @@ name: changlian description: 畅联 —— 公司内部通讯 App(手机端) publish_to: "none" -version: 1.0.4+5 +version: 1.0.5+6 environment: sdk: ">=3.6.0 <4.0.0"