During development, flutter run uses debug mode with hot reload. For release you build in release mode, where Dart code is compiled ahead of time to native machine code (or to JavaScript or WebAssembly on the web), producing smaller and faster apps. This chapter covers per-platform build commands, versioning, signing and store releases.
flutter build defaults to release mode and writes output under build, in a platform-specific location. Each target must be built on its own OS: iOS and macOS on a Mac, Windows on Windows.
# Android: App Bundle for the Play Store
flutter build appbundle
# Android: one APK per ABI (smaller files)
flutter build apk --split-per-abi
# Web: deploying under a sub-path
flutter build web --base-href /myapp/
# Try release mode on a device
flutter run --release
Version numbers
The app version lives in one place: version in pubspec.yaml. For 1.2.0+5, the user-facing version name is 1.2.0 and the build number the stores use is 5. Increase the build number for every upload; you can also override both at build time:
flutter build appbundle --build-name=1.2.1 --build-number=6
Android signing
Google Play requires builds signed with an upload key. Create a keystore with Java's keytool:
keytool -genkey -v -keystore ~/upload-keystore.jks -keyalg RSA \
-keysize 2048 -validity 10000 -alias upload
Put the passwords and keystore path in android/key.properties, and keep that file and the keystore out of version control. Then read those values in android/app/build.gradle.kts and attach the signing config to the release build:
import java.io.FileInputStream
import java.util.Properties
val keystoreProperties = Properties()
val keystorePropertiesFile = rootProject.file("key.properties")
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(FileInputStream(keystorePropertiesFile))
}
android {
// ...
signingConfigs {
create("release") {
keyAlias = keystoreProperties["keyAlias"] as String
keyPassword = keystoreProperties["keyPassword"] as String
storeFile = keystoreProperties["storeFile"]?.let { file(it) }
storePassword = keystoreProperties["storePassword"] as String
}
}
buildTypes {
release {
signingConfig = signingConfigs.getByName("release")
}
}
}
With Play App Signing, Google stores the app signing key and you only manage the upload key. Before release, double-check the applicationId, app name, icon and requested permissions.
Releasing on iOS
Publishing to the App Store requires membership in the Apple Developer Program.
- Register the app in App Store Connect and choose its bundle identifier.
- Open
ios/Runner.xcworkspace in Xcode and set the team and bundle identifier under Signing & Capabilities. - Run
flutter build ipa. Output goes to build/ios/ipa and build/ios/archive. - Upload the build with Apple's Transporter app or the Xcode Organizer, test it through TestFlight, then submit it for review.
Web and desktop
The web build in build/web is a set of static files, so any static host works: Firebase Hosting, GitHub Pages, Nginx and so on. If the app uses in-app paths, configure the server to serve index.html for every route.
The Windows build lands in build/windows/x64/runner/Release; ship the executable together with its DLLs and the data folder. The msix package can produce an MSIX installer for the Microsoft Store. macOS apps are signed in Xcode and notarized before distribution.
Obfuscation and release checklist
Release builds for Android, iOS and desktop can obfuscate Dart code. Keep the generated symbol files; you need them to read crash stack traces.
flutter build appbundle --obfuscate --split-debug-info=build/symbols
Before shipping, check:
- Performance and behavior in release mode on real devices (
flutter run --release) - App icon and launch screen (packages such as
flutter_launcher_icons help) - Store listing details: privacy policy, description, screenshots and content rating
- That
flutter analyze and flutter test both pass
Summary
- Ship by producing release builds with
flutter build <target>. - Manage the version with
version (name plus build number) in pubspec.yaml. - Upload a signed App Bundle on Android; on iOS, configure signing in Xcode and upload the output of
flutter build ipa. - Host web builds as static files and distribute the whole build folder for desktop apps.
Learn more in the official documentation:
0 comments
Sign in · Sign in to leave a comment.