Files
tongxunruanjian/mobile/android/app/build.gradle.kts
T
KIMI 9074b5d1d7 fix: 修复 release 包消息组件永久无响应(B-58 用户手机登录卡死的根因)
根因两条,叠加导致 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
2026-08-15 16:38:33 +08:00

72 lines
2.5 KiB
Kotlin
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
plugins {
id("com.android.application")
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id("dev.flutter.flutter-gradle-plugin")
}
android {
namespace = "cn.shengshentech.changlian"
compileSdk = flutter.compileSdkVersion
ndkVersion = flutter.ndkVersion
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = "cn.shengshentech.changlian"
// You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config.
minSdk = flutter.minSdkVersion
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName
}
// 压缩打包 .so(默认未压缩存储,OpenIM/WebRTC 的 native 库让包多占近一倍体积);
// 代价是安装时多解压一次,对内网分发来说体积更关键。
packaging {
jniLibs {
useLegacyPackaging = true
}
}
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")
}
}
}
kotlin {
compilerOptions {
jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17
}
}
flutter {
source = "../.."
}
// livekit_client 插件硬编码 compileSdk = 34,但它依赖的 flutter_webrtc 要求消费者 ≥36
// AAR 元数据校验会因此失败。:app 先于各插件求值(根脚本有 evaluationDependsOn(":app")),
// 所以在插件求值完成后把它的 compileSdk 抬到 36。
rootProject.subprojects {
if (name == "livekit_client") {
afterEvaluate {
extensions.configure<com.android.build.gradle.LibraryExtension> {
compileSdk = 36
}
}
}
}