Some checks failed
Build and release debug APK / Build APK (pull_request) Failing after 3m55s
Android Setup
Keystore setup
keytool -genkey -v -keystore release.keystore -keyalg RSA -keysize 2048 -validity 10000 -alias upload
- This is required to store local credentials securely and more importantly to sign the app for google play store distribution.
Using secret credentials during build
Following the guide under https://developers.google.com/maps/flutter-package/config#android_1.
- Add the following to
android/build.gradle:buildscript { dependencies { classpath "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin:2.0.1" } } - Add the following to
android/app/build.gradle:plugins { // ... id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin' } - Add the credentials to
android/secrets.properties:MAPS_API_KEY=YOUR_API_KEY - Reference the credentials in
android/app/src/main/AndroidManifest.xml:<meta-data android:name="com.google.android.geo.API_KEY" android:value="${MAPS_API_KEY}" />
Signing the app
Compared to the flutter template application, a few changes have to be made:
- Added to
android/app/build.gradle:signingConfigs { release { keyAlias = secretProperties['keyAlias'] keyPassword = secretProperties['keyPassword'] storeFile = secretProperties['storeFile'] ? file(secretProperties['storeFile']) : null storePassword = secretProperties['storePassword'] } } - Changed the
buildTypesto use thereleasesigning config:This makes use of thebuildTypes { release { signingConfig signingConfigs.release } }secretPropertiesdefined previously:secretPropertiesFile.withReader('UTF-8') { reader -> secretProperties.load(reader) }