apache / apache/cordova-android

build variants

Open
#1,134 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
3.8k
Forks
1.6k
Avg merge
16h 18m
Merged PRs (30d)
11

Description

# Feature Request: Build Variants

## Motivation Behind Feature

I would like the ability to create a development test version of my app. The dev version of the app should be able to be installed on devices alongside the latest release version. To allow this, I must change the app id to something unique. I also want to change the name to "appname-dev" to distinguish it from the release version on the user's app launcher.

Native Android has variants: https://developer.android.com/studio/build/build-variants

Native iOS has targets: https://developer.apple.com/library/archive/documentation/ToolsLanguages/Conceptual/Xcode_Overview/WorkingwithTargets.html

I searched and found some other people expressing similar interest:
https://stackoverflow.com/questions/35731142/build-variants-with-ionic-cordova
https://stackoverflow.com/questions/53521813/manage-multiple-build-variants-using-cordova-ionic-android-prject

## Feature Description

I want to be able to specify a build variant (or target?) on the CLI.
```
cordova build android --variant=dev
```
That would change the built app's widget id to "com.myco.appname_dev" and the name to "appname-dev".

To make this feature more general-purpose, perhaps the variants are defined in a file and each selects a separate config.xml.

## Alternatives or Workarounds

Currently I am editing config.xml by hand to change the id and name properties. But it is error-prone and tedious.
Also, each time I change the ID, it seems I have to remove and re-add the platforms to avoid build errors.

Contributor guide

Open the contributing guide

Research direction

Start by tracing how the CLI handles `cordova build android` and how `config.xml` supplies the app ID and name. Compare the requested `--variant=dev` behavior with Android build variants and determine how variant-specific configuration would be selected; done means a development build can be installed beside the release build with the requested ID and name.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, javascript
Domain
build-system, cli, mobile
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.