From 2252b72a14bdc8a13b5794f8d77a6d52c7d7c31a Mon Sep 17 00:00:00 2001 From: lxh2875931338 Date: Thu, 22 Oct 2026 22:34:18 +0800 Subject: [PATCH] =?UTF-8?q?build(android):=20=E4=BF=AE=E5=A4=8D=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E8=A6=86=E7=9B=96=E5=AF=BC=E8=87=B4=E7=9A=84=E6=89=93?= =?UTF-8?q?=E5=8C=85=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 恢复 versionCode/versionName 取自 pubspec(模板硬编码为 1/1.0.0) - extractNativeLibs 从 Manifest 移到 packaging.jniLibs.useLegacyPackaging(AGP 9 要求) - 恢复 kotlin.incremental=false / kotlin.parallel.tasks.in.project=false(模板覆盖时丢失) 已用 gradlew assembleDebug 验证:BUILD SUCCESSFUL,APK 内每个 ABI 仅一份 libmpv.so + libmediakitandroidhelper.so。 依赖解析已用 :app:dependencies --refresh-dependencies 验证可直连 Maven Central,无需镜像。 --- android/app/build.gradle.kts | 17 +++++++++++++++-- android/app/src/main/AndroidManifest.xml | 3 +-- android/gradle.properties | 3 +++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index f494b5b..c5384a7 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -25,8 +25,21 @@ android { // is added automatically by Flutter. (https://developer.android.com/studio/build/configure-apk-splits#configure-APK-versions) // You can force using the value of versionCode by specifying the `-P force-version-code-ignoring-abi=true` // flag during build. - versionCode = 1 - versionName = "1.0.0" + versionCode = flutter.versionCode + versionName = flutter.versionName + + // 与 main 分支保持一致:仅打包 arm64-v8a + ndk { + abiFilters.addAll(listOf("arm64-v8a")) + } + } + + // AGP 9 不再允许在 AndroidManifest 里写 android:extractNativeLibs, + // 改为在这里声明,效果等价于原先的“强制提取 .so” + packaging { + jniLibs { + useLegacyPackaging = true + } } buildTypes { diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 15d5279..f933c72 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -14,8 +14,7 @@ android:icon="@mipmap/ic_launcher" android:label="清听" android:usesCleartextTraffic="true" - android:foregroundServiceType="mediaPlayback" - android:extractNativeLibs="true"> + android:foregroundServiceType="mediaPlayback">