cordova-android icon indicating copy to clipboard operation
cordova-android copied to clipboard

Not run android apk with multiple Flavors

Open horaas opened this issue 4 years ago • 2 comments

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

horaas avatar Sep 21 '21 15:09 horaas

I have the same problem with error : Could not find any APKs to deploy Any suggestion ?

hejercherbib avatar Oct 19 '21 14:10 hejercherbib

it seems to be related to this https://github.com/apache/cordova-android/issues/1128 but no real solution provided :(

hejercherbib avatar Oct 19 '21 15:10 hejercherbib