Skip to content

Commit

Permalink
[android] fix signing key config for release APKs (again) (Lacerte#338)
Browse files Browse the repository at this point in the history
063ec6b caused release APKs to be built
without a signing config, thus failing to install. This commit "reverts"
that one, but fixes `flutter build apk --release` erroring if no
`key.properties` file exists.
  • Loading branch information
triallax authored Jul 9, 2022
1 parent f8b35ca commit 7fb59fc
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

def keystoreProperties = null
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

Expand Down Expand Up @@ -50,6 +57,23 @@ android {
versionName flutterVersionName

}

if (keystoreProperties != null) {
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile']
storePassword keystoreProperties['storePassword']
}
}
}

buildTypes {
release {
signingConfig keystoreProperties == null ? signingConfigs.debug : keystoreProperties.release
}
}
}

flutter {
Expand Down

0 comments on commit 7fb59fc

Please sign in to comment.