NativeScript / NativeScript/nativescript-cli
CLI 8.2.x does not respect the targetSdk from AndroidManifest.xml
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.1k
- Forks
- 204
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 8
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Inspect platforms/android/gradle.properties and platforms/android/app/build.gradle, focusing on computeTargetSdkVersion. Reproduce with App_Resources/Android/src/main/AndroidManifest.xml and ns build android, then check the manifest-merger-blame report or generated APK. Done means a manifest targetSdkVersion of 30 remains 30 instead of becoming 31.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, javascript
- Domain
- build-system, cli, mobile-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100