NativeScript / NativeScript/nativescript-cli

CLI 8.2.x does not respect the targetSdk from AndroidManifest.xml

Open
#5,664 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug-pending-triage
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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.