NativeScript / NativeScript/nativescript-cli

Multiple flavors in Android project: no way to specify which APK to run after build

Open
#3,538 3 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature os: android run
Dominant language
JavaScript
Stars
1.1k
Forks
204
Avg merge
1d 9h
Merged PRs (30d)
8

Description

Did you verify this is a real problem by searching the NativeScript Forum and the other open issues in this repo?

yes.

Tell us about the problem

When specifying multiple flavors in the app.gradle and thus more than one APK gets generated during build, the CLI prints a warning More than one .apk found in ... directory. Using the last one produced from build.

So depending on Gradle's internal workings when doing a tns run android the APK that was built first is picked. Which may not be the right one in this case.

https://github.com/NativeScript/nativescript-cli/blob/8cd21b8f437eb37c14d0bd1df9babce7f53d7ee9/lib/services/platform-service.ts#L800

Would be great if the CLI would have an option to specify which flavor (or APK) to be used on tns run

Which platform(s) does your issue occur on?

macOS, Android build

Please provide the following version numbers that your issue occurs with:
  • CLI: 4.0.0
  • Cross-platform modules: tns-core-modules 4.0.1
  • Runtime(s): tns-androd 4.0.1

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

Start in lib/services/platform-service.ts around the linked APK-selection logic and review how tns run android handles multiple APKs produced from app.gradle flavors. Define the CLI option and its expected flavor or APK selection behavior, then verify that tns run android consistently launches the requested APK instead of relying on build order.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, javascript
Domain
cli, mobile
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.