apache / apache/cordova-android

Not run android apk with multiple Flavors

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

Description

# Bug Report

**Not run android apk with multiple Flavors, when using the command "cordova run android"**

## Problem

### What is expected to happen?
the app is expected to run with custom flavors

### What does actually happen?

I have the following configuration

**my build-extras.gradle**

def outputFileNameGeneral
def fileName

if (project.hasProperty('projectName')) {
fileName = projectName
} else {
fileName = project.name
}

def environmentProperties = new Properties()
def hascountryProperties = rootProject.file("environment.properties")
def cdvBuildEnvironment
def manifest = new XmlSlurper().parse(file(android.sourceSets.main.manifest.srcFile))

if (hascountryProperties.exists()) {
environmentProperties.load(new FileInputStream(hascountryProperties))
cdvBuildEnvironment = environmentProperties['cdvBuildEnvironment']
}

android {
useLibrary 'org.apache.http.legacy'
buildTypes {
debug {
debuggable true
}
release {
debuggable false
}
}

flavorDimensions "environment"

productFlavors {
if (cdvBuildEnvironment == "developer") {
developer {
dimension "environment"
buildConfigField "String", "environment", "\"dev\""
}
}
if (cdvBuildEnvironment == "production") {
production {
dimension "environment"
buildConfigField "String", "environment", "\"prod\""
}
}
}
outputFileNameGeneral = "${fileName}-${cdvBuildEnvironment}-${manifest."@android:versionCode".text()}"
setProperty("archivesBaseName", "${outputFileNameGeneral}")
}

android.applicationVariants.all { variant ->
variant.outputs.all { output ->
outputFileName = "${outputFileNameGeneral}.apk"
}
}

my enviroment.properties
`cdvBuildEnvironment=developer or production`

### Command or Code

when using the command **"cordova run android"**
the following result is obtained
`platforms/android/app/build/outputs/apk/developer/debug/app-developer-10000.apk`

in console
`Could not find any APKs to deploy`

### Version information

`cordova cli 10.0.0`
`cordova android 10.1.1`
`npm 7.13.0`
`node 14.17.0`

Contributor guide

Open the contributing guide

Research direction

Start by reproducing `cordova run android` with the reported `build-extras.gradle` and `environment.properties` flavor configuration. Compare the generated APK path under `platforms/android/app/build/outputs/apk/developer/debug/` with the deployment step; done means the selected flavor APK is found and installed by the command.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, javascript
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.