diff --git a/bin/templates/project/legacy/build.gradle b/bin/templates/project/legacy/build.gradle index 245f7037..ef229719 100644 --- a/bin/templates/project/legacy/build.gradle +++ b/bin/templates/project/legacy/build.gradle @@ -25,8 +25,12 @@ buildscript { jcenter() } + // Switch the Android Gradle plugin version requirement depending on the + // installed version of Gradle. This dependency is documented at + // http://tools.android.com/tech-docs/new-build-system/version-compatibility + // and https://issues.apache.org/jira/browse/CB-8143 dependencies { - classpath 'com.android.tools.build:gradle:2.3.0' + classpath 'com.android.tools.build:gradle:2.2.3' } } @@ -39,7 +43,7 @@ allprojects { } task wrapper(type: Wrapper) { - gradleVersion = '3.3.0' + gradleVersion = '2.14.1' } // Configuration properties. Set these via environment variables, build-extras.gradle, or gradle.properties. @@ -94,11 +98,9 @@ if (hasBuildExtras) { // Set property defaults after extension .gradle files. if (ext.cdvCompileSdkVersion == null) { ext.cdvCompileSdkVersion = privateHelpers.getProjectTarget() - //ext.cdvCompileSdkVersion = project.ext.defaultCompileSdkVersion } if (ext.cdvBuildToolsVersion == null) { ext.cdvBuildToolsVersion = privateHelpers.findLatestInstalledBuildTools() - //ext.cdvBuildToolsVersion = project.ext.defaultBuildToolsVersion } if (ext.cdvDebugSigningPropertiesFile == null && file('debug-signing.properties').exists()) { ext.cdvDebugSigningPropertiesFile = 'debug-signing.properties' @@ -109,7 +111,7 @@ if (ext.cdvReleaseSigningPropertiesFile == null && file('release-signing.propert // Cast to appropriate types. ext.cdvBuildMultipleApks = cdvBuildMultipleApks == null ? false : cdvBuildMultipleApks.toBoolean(); -ext.cdvMinSdkVersion = cdvMinSdkVersion == null ? null : defaultMinSdkVersion +ext.cdvMinSdkVersion = cdvMinSdkVersion == null ? null : Integer.parseInt('' + cdvMinSdkVersion) ext.cdvVersionCode = cdvVersionCode == null ? null : Integer.parseInt('' + cdvVersionCode) def computeBuildTargetName(debugBuild) { @@ -148,9 +150,7 @@ task cdvPrintProps << { } android { - - //Define a sourceset only if we have a top level AndroidManifest.xml file - sourcesets { + sourceSets { main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] @@ -179,11 +179,6 @@ android { compileSdkVersion cdvCompileSdkVersion buildToolsVersion cdvBuildToolsVersion - //This code exists for Crosswalk and other Native APIs. - //By default, we multiply the existing version code in the Android Manifest by 10 and - //add a number for each architecture. If you are not using Crosswalk or SQLite, you can - //ignore this chunk of code, and your version codes will be respected. - if (Boolean.valueOf(cdvBuildMultipleApks)) { productFlavors { armv7 { @@ -205,6 +200,22 @@ android { } } } + /* + + ELSE NOTHING! DON'T MESS WITH THE VERSION CODE IF YOU DON'T HAVE TO! + + else if (!cdvVersionCode) { + def minSdkVersion = cdvMinSdkVersion ?: privateHelpers.extractIntFromManifest("minSdkVersion") + // Vary versionCode by the two most common API levels: + // 14 is ICS, which is the lowest API level for many apps. + // 20 is Lollipop, which is the lowest API level for the updatable system webview. + if (minSdkVersion >= 20) { + defaultConfig.versionCode += 9 + } else if (minSdkVersion >= 14) { + defaultConfig.versionCode += 8 + } + } + */ compileOptions { sourceCompatibility JavaVersion.VERSION_1_6 @@ -233,18 +244,9 @@ android { } } -/* - * WARNING: Cordova Lib and platform scripts do management inside of this code here, - * if you are adding the dependencies manually, do so outside the comments, otherwise - * the Cordova tools will overwrite them - */ - - dependencies { compile fileTree(dir: 'libs', include: '*.jar') // SUB-PROJECT DEPENDENCIES START - debugCompile(project(path: ":CordovaLib", configuration: "debug")) - releaseCompile(project(path: ":CordovaLib", configuration: "release")) // SUB-PROJECT DEPENDENCIES END }