Publishing a Flutter app to the Play Store
I'll skip details for the first few steps.
Set up an empty app
Empty app
Test on Android and iOS VM
Set up BitBucket repo
git init
git add .
git commit -a -m 'initial commit.'
Publish to Play Store as Alpha
I followed the Flutter doc on deploying (doc) and my own post back when I did it for a pure Android app (post).
Set up the App Icon
Flutter launcher icon tool
It is different from my previous post since it should work on both Android and iOS. The Flutter launcher icon tool lets you set up a config file to pick which icon you want, then it will set up all the Android and iOS artifacts and configs for you.
Adaptive icon
It can even set up adaptive icons for you, which is useful for people who use non stock Android phones. See this doc.
To do this, I made two versions of the icon, one with and one without a shape. Without the shape I get simply the icon with transparent background.
The final config for my pubspec.yaml is like so:
flutter_icons:
android: true
ios: true
image_path: "assets/icon/icon.png"
adaptive_icon_background: "#448AFF"
adaptive_icon_foreground: "assets/icon/icon-foreground.png"
Finally I ran the tool and got:
$ flutter pub pub run flutter_launcher_icons:main
Android minSdkVersion = 16
Creating icons Android
Overwriting default Android launcher icon with new icon
Creating adaptive icons Android
Overwriting default iOS launcher icon with new icon
Copying colors.xml template to project
Found existing background color value
$
Setting the version
The app version code and version name are set in pubspec.yaml. The version field is set like so: version: 0.6.0+9
means versionName 0.6.0 and buildCode 9.
Signing the app
I reused the keystore I made last time. Unlike regular Android apps, there is no UI in Android Studio to do so. Instead you have to modify a few config files manually. See the full docs here: https://flutter.dev/docs/deployment/android#configure-signing-in-gradle.
In app/build.gradle
, before android {...
, load the properties file:
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('../../key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
Then inside android {...
:
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
if (keystoreProperties['storeFile'] != null) {
storeFile file(keystoreProperties['storeFile'])
}
storePassword keystoreProperties['storePassword']
}
}
In buildTypes, release, use this new signing config:
buildTypes {
release {
signingConfig signingConfigs.release
}
}
$ flutter build apk
Initializing gradle... 1.5s
Resolving dependencies... 1.2s
Gradle task 'assembleRelease'...
Gradle task 'assembleRelease'... Done 9.2s
Built build/app/outputs/apk/release/app-release.apk (5.4MB).
$
Enabling Pro-Guard
This is for minimizing the file and obfuscating it. I will do that later and compare sizes.
Play Console settings
I set up artifacts (screenshots, icon, feature graphic) as described in my older post.
I then set up an Alpha release, whitelist users, publish the first build. It took 15 minutes to release. Maybe because I had selected all 143 available countries?
Finally I had to opt-in in order to see it in the Play Store.
And finally, I got installed and running on my phone!
Next steps
I'd want to try deploying to the iOS Store as an exercise. I have an iPad, although I don't plan to use it for Flashcards.
I'd also want to try using fastlane, a continuous deployment tool recommended by the Flutter team.