Reputation: 23
I am trying to generate an appbundle. I've got a key.jks file already ready to go. As far as I know, I've followed Flutter.dev/AndroidDeployment correctly? This is my first app deployment. Is manually changing the build.gradle file the best way to go? I know there's a UI structure element that has drop menus and such in Android Studio that I've tried to no success. Anyways, like I said, all I've done is follow Flutter.dev on Android deployment and now I'm stuck and I think my issue lies somewhere within build.gradle considering that it always shows red error lines under it. Can someone take a look at what I've got and lead me in the right direction? I've changed the private parts for obvious reasons. Thanks!
Here is the code:
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
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 plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
compileSdkVersion 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
applicationId "com.changed_text.techhelprelease"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0.0"
signingConfig signingConfigs.release
}
signingConfigs {
release {
keyAlias keystoreProperties['key']
keyPassword keystoreProperties['changedText']
storeFile keystoreProperties['C:\\changedText\\key.jks'] ? file(keystoreProperties['C:\\changedText\\key.jks']) : null
storePassword keystoreProperties['changedText']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
Upvotes: 0
Views: 565
Reputation: 23
The problem was this:
signingConfigs {
release {
keyAlias keystoreProperties['key']
keyPassword keystoreProperties['changedText']
storeFile keystoreProperties['C:\\changedText\\key.jks'] ? file(keystoreProperties['C:\\changedText\\key.jks']) : null
storePassword keystoreProperties['changedText']
}
}
Should have stayed default from Flutter.dev, which is this:
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
And then I figured out that I must have accidentally pasted the signature line where it didn't belong, which was throwing me an error every time. So this:
defaultConfig {
applicationId "com.changed_text.techhelprelease"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0.0"
signingConfig signingConfigs.release
}
Should not have the last line. Corrected:
defaultConfig {
applicationId "com.changed_text.techhelprelease"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0.0"
}
Upvotes: 1