根因(用远程日志的 STORAGE 行 + 本地复现 Muse 协议定位): - 曲库服务 mconn.cherryonline.cn 与点歌登录 mws.cherryonline.cn 都用 Let's Encrypt 新链 leaf ← YR2 ← Root YR ← ISRG Root X1。 - res/xml/network_security_config.xml 里虽然已把这三个根加为信任锚,但 **该配置只在 Android 7.0(API 24)+ 被系统读取**;Android 5.1.1 上被完全忽略, 系统信任库又没有 ISRG 新根 → SSLHandshakeException: Trust anchor for certification path not found → login 失败 → fetchVersion()=null → 根本不触发下载, 界面只剩兜底文案「未找到可用曲库」,而失败只写 logcat,远程日志里看不到。 - 这也解释了为什么只有这台老设备出问题(其它设备都 >= API 24)。 修复: - 新增 TlsCompat: 在 API<24 上把「系统默认信任 ∪ 内置根证书」的复合 X509TrustManager 装到全局 HttpsURLConnection.setDefaultSSLSocketFactory,覆盖 App 内所有 HttpsURLConnection (曲库同步/JS 热更新下载/更新检查/头像下载)。主机名校验保持系统默认,不放行任意证书。 - WebView 的 TLS 无法用 SSLContext 覆盖(JS 会直连 mws): 在 KtvJsBridge 的 onReceivedSslError 里不盲目 proceed,先用 TlsCompat.isHostTrustedByOurStore(host) 对同一主机独立校验,通过才放行。 - TlsCompat.install 在 KtvApplication.attachBaseContext 调用(早于任何网络请求)。 - 补齐可观测性: 曲库同步每一步失败改为 MiliLog 上报 (MUSE-DB login/sync ...、DB-SYNC download failed/空间不足/成功); fetchRemoteVersion 失败时设置明确的 bootstrapError,不再只显示兜底文案。 - AGENTS.md 增补「老系统 TLS 根证书」条目。 版本 1.4.2(22) → 1.4.3(23);签名证书不变。
105 lines
3.6 KiB
Groovy
105 lines
3.6 KiB
Groovy
plugins {
|
|
id "com.android.application"
|
|
id "org.jetbrains.kotlin.android"
|
|
}
|
|
|
|
android {
|
|
namespace "com.local.ktv"
|
|
compileSdk 35
|
|
|
|
defaultConfig {
|
|
applicationId "com.local.ktv"
|
|
minSdk 21
|
|
targetSdk 25
|
|
versionCode 23
|
|
versionName "1.4.3"
|
|
ndk {
|
|
// 双 ABI 打包:兼容 64 位(Exynos 1580 等 arm64-v8a)与 32 位设备(极米 Play 超越版
|
|
// 的 Amlogic 950X2/S905X2 采用 32 位 Android 用户态,必须包含 armeabi-v7a,否则
|
|
// 会出现 INSTALL_FAILED_NO_MATCHING_ABIS 安装失败)。
|
|
// Package each ABI's complete IJK set; never mix individual SOs across the two sets.
|
|
abiFilters "armeabi-v7a", "arm64-v8a"
|
|
}
|
|
// 曲库已改为官方 Muse 同步(database_publish 不再发布到 Gitee),
|
|
// 不再需要 GITEE_DATABASE_* 构建参数。
|
|
}
|
|
|
|
// 签名配置:使用已有的 ktv_keystore.jks
|
|
signingConfigs {
|
|
release {
|
|
storeFile file("../../ktv_keystore.jks")
|
|
storePassword "123456"
|
|
keyAlias "ktv"
|
|
keyPassword "123456"
|
|
}
|
|
}
|
|
|
|
buildTypes {
|
|
release {
|
|
minifyEnabled true
|
|
shrinkResources true
|
|
signingConfig signingConfigs.release
|
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
|
}
|
|
debug {
|
|
debuggable true
|
|
applicationIdSuffix ".qa"
|
|
}
|
|
}
|
|
|
|
// 支持 .ts 视频文件(aapt 不压缩这些文件以避免 SoundPool/MediaPlayer 问题)
|
|
androidResources {
|
|
noCompress 'ts', 'mp3', 'mp4', 'aac', 'm4a', 'flac', 'wav'
|
|
}
|
|
|
|
// lint 策略:
|
|
// - 「调用了高于 minSdk 且未做版本守卫的 API」(NewApi) 必须**阻断发布构建**:
|
|
// 这类问题在 Android 5.x / 6.x 上直接 NoSuchMethodError / NoClassDefFoundError 闪退,
|
|
// 而本地打包测试用的都是较新设备, 极容易漏出去(v1.4.0 在极米 H1S / Android 5.1.1
|
|
// 一打开就闪退, 根因就是 AudioDeviceCallback(API 23) 被写进了 Activity 的字段初始化器)。
|
|
// - ExpiredTargetSdkVersion 默认也是 fatal 级, 但本地分发的 APK 不上架 Google Play,
|
|
// 显式关掉, 否则会挤占下面这道闸门。
|
|
// - abortOnError 必须为 true: 设为 false 会把 lintVital 的失败一并吞掉, 闸门会失效。
|
|
lint {
|
|
fatal += ['NewApi']
|
|
disable += ['ExpiredTargetSdkVersion']
|
|
checkReleaseBuilds true
|
|
abortOnError true
|
|
}
|
|
|
|
// 启用 BuildConfig 生成,供 AboutFragment 读取版本号/版本Code等信息
|
|
buildFeatures {
|
|
buildConfig = true
|
|
}
|
|
|
|
compileOptions {
|
|
sourceCompatibility = JavaVersion.VERSION_17
|
|
targetCompatibility = JavaVersion.VERSION_17
|
|
}
|
|
|
|
kotlinOptions {
|
|
jvmTarget = "17"
|
|
}
|
|
|
|
}
|
|
|
|
// 强制统一 Kotlin 标准库版本,避免 appcompat 与其他依赖的版本冲突
|
|
configurations.all {
|
|
resolutionStrategy {
|
|
force "org.jetbrains.kotlin:kotlin-stdlib:1.8.22"
|
|
force "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.22"
|
|
force "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22"
|
|
force "org.jetbrains.kotlin:kotlin-stdlib-common:1.8.22"
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
implementation files('libs/original-ijk-runtime.jar')
|
|
implementation "androidx.core:core:1.12.0"
|
|
implementation "androidx.appcompat:appcompat:1.6.1"
|
|
implementation "com.google.zxing:core:3.5.3"
|
|
implementation "com.liulishuo.okdownload:okdownload:1.0.7"
|
|
testImplementation "junit:junit:4.13.2"
|
|
|
|
}
|