Update examples to match the new version of generated build.gradle (#25483) (#25569)

This version honors flutter tool's --build-number/--build-name flags.
This commit is contained in:
Stanislav Baranov
2018-12-19 12:16:30 -08:00
committed by GitHub
parent 316d74f62d
commit da599cfc59
8 changed files with 120 additions and 40 deletions

View File

@@ -1,8 +1,8 @@
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withInputStream { stream ->
localProperties.load(stream)
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
@@ -11,6 +11,16 @@ if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
@@ -25,8 +35,8 @@ android {
applicationId "io.flutter.examples.flutter_view"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "0.0.1"
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}