Repository navigation
feat(android): add Android 5.0+ (API 21) compatibility via multi-level Gradle property - #319
Merged
Merged
Conversation
Member
|
冲突 |
…perty Add non-breaking support for Android 5.0+ devices and 32-bit architectures through a multi-level Gradle property switch (-Pmicyou.androidCompat=api21). ## Build System - **Multi-level compatibility parameter**: Changed from boolean to numeric/string level design (api21, extensible to api19, etc.). Default (no flag) = upstream behavior unchanged. - **Version catalog overrides**: settings.gradle.kts overrides AGP (9.3.1→8.9.1), Kotlin (2.4.10→2.3.10), Compose BOM (2026.05.00→2024.09.00), and other dependency versions via versionCatalogs.version() when compat mode is enabled. - **lib.versions.toml**: Added compat-* version entries without modifying originals. - **composeApp/build.gradle.kts**: Conditional configuration for minSdk (24→21), targetSdk (36→29), MultiDex, core library desugaring, JVM target (11→1.8), 32-bit ABIs (armeabi-v7a, x86), and resolutionStrategy force downgrades. ## Source Set Bridge Layer For libraries with large API differences (haze, materialKolor/ExpressiveColorScheme): - src/normal/ — normal mode: delegates to original libraries (haze 1.7.2, etc.) - src/compat/ — compat mode: downgraded implementations (semi-transparent fallback) - src/main/ imports from bridge package, no direct library references ## Runtime Compatibility (always active, guarded by SDK_INT) - AudioRecord: float PCM read and READ_NON_BLOCKING fallback for API < 23 - AudioService: NotificationChannel, PendingIntent.FLAG_IMMUTABLE, setExactAndAllowWhileIdle, startForeground(3-arg) all guarded by version checks - MainActivity: startForegroundService() fallback for API < 26 - PermissionDialog: POST_NOTIFICATIONS runtime request only for API 33+ - AudioSettings: availableAudioFormats() filters PCM_FLOAT below API 23 - AudioStreamViewModel: default audio format based on device API level - Material3: ColorSchemeCompat for dynamic color roles below API 31 ## Application & Manifest - MicYouApplication: Reflective MultiDex.install() + global crash log handler - AndroidManifest: android:name, tools:ignore for high-version permissions, tools:overrideLibrary for minSdk conflicts ## Documentation - Android_兼容性编译说明.md: Complete build guide, version comparison table, runtime compatibility list, source set bridge explanation, and verification steps ## Non-destructive Guarantee - Default build identical to upstream (no flag = no change) - Only adds entries, never modifies original version values - All runtime checks use Build.VERSION.SDK_INT guards - Reflective MultiDex call silently skips when dependency absent
luminset
force-pushed
the
compat/v2.0.1
branch
from
August 26, 2026 22:54
ada00d8 to
b429c89
Compare
Contributor
Author
我刚提交了基于最新代码的更新,看看是否能够解决冲突? |
Contributor
Author
|
你好~注意到 opencode 这个 CI check 在本 PR 上失败了,想分享一下我的观察,供参考: 错误信息是
这意味着 opencode 在所有 fork 提交的 PR 上可能都会失败,属于预期行为,与本 PR 的代码改动无关。本 PR 的其他构建 check(Android + 三个 Tauri 平台)均已全部通过。 如果后续希望 opencode 也能在 fork PR 上运行,可能需要考虑:
以上仅供维护者参考,如有不对的地方欢迎指正~ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
为 Android 端添加 Android 5.0+ (API 21) 和 32 位设备的兼容性支持,通过多级别 Gradle 属性开关控制,完全非破坏性——默认不加参数时编译结果与上游完全一致。
本 PR 基于最新 master (commit 90aaf76) 重新构建,已解决此前 rebase 不及时导致的兼容性问题。
实现方式
通过多级别 Gradle 属性
-Pmicyou.androidCompat=<level>切换兼容模式:api21→ Android 5.0+ 兼容模式api19等更低级别构建命令
原版(与上游一致):
兼容版(Android 5.0+):
构建系统改动
versionCatalogs.version()覆盖版本号,兼容模式下自动降级 AGP (9.3.1→8.9.1)、Kotlin (2.4.10→2.3.10)、Compose BOM (2026.05.00→2024.09.00) 等依赖compat-*系列版本条目,原版本值不动Source Set 桥接层
对 API 差异较大的库(haze、ExpressiveColorScheme)采用 source set 桥接方案:
src/normal/— 正常模式:委托给原版库src/compat/— 兼容模式:降级实现(半透明背景替代 haze 模糊等)src/main/仅从桥接包导入,无需修改运行时兼容(始终生效,SDK_INT 守卫)
read(float[], READ_NON_BLOCKING)API 23+read(ByteBuffer)+asFloatBuffer()间接读取READ_NON_BLOCKINGAPI 23+startForegroundService()API 26+startService()+ 内部startForeground()NotificationChannelAPI 26+FLAG_IMMUTABLEAPI 23+FLAG_UPDATE_CURRENTsetExactAndAllowWhileIdle()API 23+setExact()非破坏性保证
compat-*条目,不修改原版本值验证
-Pmicyou.androidCompat=api21)详细说明见
Android_兼容性编译说明.md。