NativeScript / NativeScript/nativescript-cli
CLI 8.2.x does not respect the targetSdk from AndroidManifest.xml
还没有人认领这个 Issue。
- 主要语言
- JavaScript
- 星标
- 1.1k
- 派生
- 204
- 平均合并
- 1 天 9 小时
- 30 天内合并 PR
- 8
描述
Issue Description
After we upgraded to {N} 8.2.2 we found that during build, the CLI sets the targetSdk to 31 instead of respecting the value in App_Resources/Android/src/main/AndroidManifest.xml which was in our case set to 30.
The merged, final manifest in the APK has targetSdk 31
This is read from platforms/android/gradle.properties, defined as NS_DEFAULT_COMPILE_SDK_VERSION=31, applied in the platforms/android/app/build.gradle file through
def computeTargetSdkVersion = { -> project.hasProperty("targetSdk") ? targetSdk : NS_DEFAULT_COMPILE_SDK_VERSION as int }
Workaround: specify targetSdk in the config/android/resources/gradle.properties, e.g.
targetSdk = 30
Reproduction
in App_Resources/Android/src/main/AndroidManifest.xml set
<uses-sdk
android:minSdkVersion="26"
android:targetSdkVersion="30"/>
run ns build android
check platforms/android/app/build/intermediates/manifest_merge_blame_file/debug/manifest-merger-blame-debug-report.txt or check the generated APK and it's embedded AndroidManifest.
Relevant log output (if applicable)
from `platforms/android/app/build/intermediates/manifest_merge_blame_file/debug/manifest-merger-blame-debug-report.txt`
7 <uses-sdk
7-->/me/dev/test/platforms/android/app/src/main/AndroidManifest.xml:13:5-15:44
8 android:minSdkVersion="26"
8-->/me/dev/test/platforms/android/app/src/main/AndroidManifest.xml:14:13-39
9 android:targetSdkVersion="31" />
9-->/me/dev/test/platforms/android/app/src/main/AndroidManifest.xml:15:13-42
Environment
No response
Please accept these terms
- I have searched the existing issues as well as StackOverflow and this has not been posted before
- This is a bug report
- I agree to follow this project's Code of Conduct
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
检查 platforms/android/gradle.properties 和 platforms/android/app/build.gradle,重点关注 computeTargetSdkVersion。使用 App_Resources/Android/src/main/AndroidManifest.xml 和 ns build android 重现,然后检查 manifest-merger-blame 报告或生成的 APK。完成的标准是,manifest 中的 targetSdkVersion 30 仍然是 30,而不是变成 31。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- android, javascript
- 领域
- build-system, cli, mobile-dev
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 42/100