The problem here is what I think is a bug in the flutter create templates. In the build.gradle files they create, they have these stanzas:
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
throw new GradleException("versionCode not found. Define flutter.versionCode in the local.properties file.")
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
The workaround for this is to change the lines in your build.gradle from something like this:
android {
compileSdkVersion 27
defaultConfig {
minSdkVersion 16
targetSdkVersion 27
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
}
to something like this:
android {
compileSdkVersion 27
defaultConfig {
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
}
and remove the flutterVersionCode and flutterVersionName stanzas.
The fix to the bug will probably be something like defaulting to a value if the version information isn't in the local.properties.
got it from this link https://github.com/flutter/flutter/issues/18983