Now you should know how to develop a very basic Flutter Apps. It’s time for the most exciting part: Launch to the market. The next big step is to deploy it to different platforms such as the Google Play Store for Android and the Apple App Store for iOS. I will share with you everything you need to know for apps deployment. At the end of this tutorial, you should be able to:
- Build a release APK for Android and configure signing.
- Prepare your app for deployment to the Google Play Store.
- Set up your iOS app for the Apple App Store.
- Configure versioning, app icons, and other deployment essentials.
Alright, let’s begin!
Step 1: Preparing Your Flutter App for Deployment
Before deploying, you should first make sure some configurations in your Flutter app are READY.
Configure App Name and Version
First and foremost, your apps name and version are critical. Many of my students always look down the important of version control. Instead, a systematic version control for an apps project is the key to success. What you need to do is open the pubspec.yaml
file in xCode or Android studio, ensure the following fields are properly set:
name: your_app_name
description: A description of your app.
# Add app versioning
version: 1.0.0+1
The format of version number is usually x.y.z+build_number. x.y.z is the app version number. build_number is an internal version number for incremental updates.
Set App Icons
The second important step is to add your own custom apps icons for both Android and iOS platforms. There are plenty of apps icon resources out there. Personally, I love to make it myself. You can easily find the Free/Paid resources in Flaticon, IconFinder, Icons8 or Freepik.
Once your apps icon ready, you can put in corresponding folders:
For Android, usually place your app icon images in the “android/app/src/main/res/mipmap-*” directories (different sizes for different screen densities).
For iOS, try the “ios/Runner/Assets.xcassets/AppIcon.appiconset/” folder.
You can also use the flutter_launcher_icons package by adding below to pubspec.yaml:
dev_dependencies:
flutter_launcher_icons: latest_version
flutter_icons:
android: true
ios: true
image_path: "assets/icon/app_icon.png"
After that, run the command to generate icons:
flutter pub run flutter_launcher_icons:main
Step 2: Building and Deploying Flutter Apps for Android
Let’s first start with the deployment to the Google Play Store. Deploying Flutter apps for Android is pretty straight forward, what you need to do is prepare a release ready APK file. So what is APK? It’s simply Android file system format, just like zip, mp3 or doc, this specific file format are a package able to run in Android operating system.
How to build a Release APK in Flutter?
By running the following command, you can create a release APK:
flutter build apk --release
This command generates an APK file optimized for release in the build/app/outputs/flutter-apk/
directory usually.
Noted that the command should be run from the root of your Flutter project. The system will look into the “pubspec.yaml” file for the build details.
Signing the APK
There are Google Play requires that your APK is signed with a release key before uploading. Here’s how to configure the signing process:
- Generate a Keystore: Run this command to generate a signing key.
keytool -genkey -v -keystore ~/my-release-key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias my-key-alias
You’ll be prompted to enter a password and other information. This creates a file named my-release-key.jks
.
- Configure Gradle for Signing: Open
android/app/build.gradle
and add the following lines under theandroid
section:
android {
...
signingConfigs {
release {
keyAlias 'my-key-alias'
keyPassword 'your-key-password'
storeFile file('path/to/my-release-key.jks')
storePassword 'your-store-password'
}
}
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
- Build the Signed APK:
flutter build apk --release
Your signed APK is now ready for upload to the Play Store.
3. Uploading to Google Play Store
- Go to the Google Play Console and create a developer account if you don’t have one.
- Create a new app by selecting Create App in the Play Console.
- Follow the steps to fill in the app’s details, such as title, description, and category.
- Upload the release APK generated in the previous steps.
- After uploading, complete the content rating, pricing, and distribution setup.
- Submit your app for review. Once approved, your app will be available on the Play Store.
Step 3: Building and Deploying for iOS
iOS deployment is a bit more involved due to Apple’s requirements. You need a macOS machine to build and release iOS apps.
1. Setting Up Xcode and Certificates
Before building your iOS app for release, you’ll need to set up your development environment with Xcode and create the necessary certificates.
- Install Xcode: Download and install Xcode from the Mac App Store.
- Create an Apple Developer Account: Sign up for the Apple Developer Program.
- Create App IDs and Certificates:
- Go to the Apple Developer Console and create an App ID for your app.
- Generate the necessary certificates (Development, Distribution, and Push Notification Certificates).
- Create a Provisioning Profile for your app.
2. Building the iOS App
- Open the iOS Project in Xcode: Open your Flutter project’s iOS folder in Xcode:
open ios/Runner.xcworkspace
- Select the Signing Team: In Xcode, navigate to the project settings (click on the Runner target) and select your signing team under Signing & Capabilities.
- Build the Release IPA: To build an iOS release app, use the following Flutter command:
flutter build ios --release
Alternatively, you can archive the app directly in Xcode by selecting Product > Archive and following the prompts.
3. Uploading to the App Store
- Open Xcode and go to Product > Archive to create an archive of your app.
- After the archive is complete, click Distribute App and follow the instructions to upload your app to the App Store using App Store Connect.
- Once uploaded, you’ll need to log in to App Store Connect and configure your app listing.
- Submit your app for review. After approval, it will be available in the App Store.
Step 4: Configuring App Permissions
You’ll need to declare the permissions your app requires in both Android and iOS platforms.
1. Android Permissions
Permissions are declared in the AndroidManifest.xml
file located in android/app/src/main/AndroidManifest.xml
.
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
2. iOS Permissions
In iOS, permissions are configured in the Info.plist
file located in ios/Runner/Info.plist
. For example, to request camera access:
<key>NSCameraUsageDescription</key>
<string>We need access to your camera to take pictures.</string>
Step 5: Managing App Versioning
Versioning is critical for app updates and is managed via the pubspec.yaml
file:
version: 1.0.0+1
- 1.0.0: This is the app version visible to users.
- +1: This is the internal build number, which should be incremented with every release.
Make sure to update the version and build number before deploying new versions of your app.
Conclusion: Deploying Your Flutter App
You now know how to prepare and deploy your Flutter app to both the Google Play Store and the Apple App Store. The deployment process includes building a release version of your app, configuring app signing, and setting up app store listings. As you deploy your app, make sure to follow platform-specific guidelines and best practices for a successful launch.
In the next tutorial, we’ll dive deeper into advanced topics like continuous integration (CI/CD) with Flutter, which can help automate your build and deployment process. Keep building, and happy coding!