You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Derek Hang (JIRA)" <ji...@apache.org> on 2017/01/11 12:12:58 UTC

[jira] [Created] (CB-12345) Android-Target is not being overrided

Derek Hang created CB-12345:
-------------------------------

             Summary: Android-Target is not being overrided
                 Key: CB-12345
                 URL: https://issues.apache.org/jira/browse/CB-12345
             Project: Apache Cordova
          Issue Type: Bug
          Components: Android
    Affects Versions: 5.4.1
         Environment: cordova-android 6.4.0
            Reporter: Derek Hang


As specified in https://cordova.apache.org/docs/en/latest/config_ref/

android-targetSdkVersion(integer) can be used to configure the target SDK.  This means that after you generate the project, it will build with this targetSDK. 

However, this is not the case. 

As a result, the ability to override the gradle files via either

gradle.properties
cdvCompileSdkVersion=23
cdvBuildToolsVersion="23.0.3"

build-extras.gradle
ext.cdvCompileSdkVersion = 23
ext.cdvBuildToolsVersion = "23.0.3"

does not work.  It will always try to use the hard coded target which is android-25 to build the project.  It will try to download the SDK and then build it.

Details
-----------------
In the CordovaLib/project.properties it hardcodes a target target=android-25.  As a result, in CordovaLib/cordova.gradle


String doGetProjectTarget() {
    def props = new Properties()
    file('project.properties').withReader { reader ->
        props.load(reader)
    }
    return doEnsureValueExists('project.properties', props, 'target')
}

will always return android-25.  

What this means is that in the CordovaLib/build.gradle 

ext {
    apply from: 'cordova.gradle'
    cdvCompileSdkVersion = privateHelpers.getProjectTarget()
    cdvBuildToolsVersion = privateHelpers.findLatestInstalledBuildTools()
}


The target will always be 25.

You can see this if you add the gradle task to the file

task cdvPrintPropsSubTest << {
    println('buildsdk=' + privateHelpers.findLatestInstalledBuildTools())
    println('target=' + privateHelpers.getProjectTarget())

    println('cdvCompileSdkVersion=' + cdvCompileSdkVersion)
    println('cdvBuildToolsVersion=' + cdvBuildToolsVersion)
    println('cdvVersionCode=' + cdvVersionCode)
    println('cdvMinSdkVersion=' + cdvMinSdkVersion)
    println('cdvBuildMultipleApks=' + cdvBuildMultipleApks)
    println('cdvReleaseSigningPropertiesFile=' + cdvReleaseSigningPropertiesFile)
    println('cdvDebugSigningPropertiesFile=' + cdvDebugSigningPropertiesFile)
    println('cdvBuildArch=' + cdvBuildArch)
    println('computedVersionCode=' + android.defaultConfig.versionCode)
    android.productFlavors.each { flavor ->
        println('computed' + flavor.name.capitalize() + 'VersionCode=' + flavor.versionCode)
    }
}

The workaround is to modify the generated files, but this defeats the purpose of being able to regenerate the code without having to worry about custom modifications to it.




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org