You’ve spent weeks perfecting your Flutter app. The widgets are beautiful, the state management is solid, and it runs perfectly on your emulator. But now comes the real challenge: getting it onto a real device.
In this guide, we’ll skip the fluff and look at exactly how to build and share your first Android APK.
1. The Quick & Dirty: Generating Your First APK
If you just want to send a file to your friend or client right now, the standard command is your best friend:
flutter build apk --release
What’s happening here?
Flutter is "tree-shaking" your code—removing unused resources—and compiling your Dart code into a high-performance release binary. Once finished, you’ll find your prize at:
build/app/outputs/flutter-apk/app-release.apk.
2. The "Fat APK" Problem (and the Solution)
The standard build command creates a "Fat APK," which contains code for all device architectures (arm64, armeabi, x86_64). While convenient, it makes your file size unnecessarily large.
To create smaller, optimized files for specific devices, use:
flutter build apk --split-per-abi
This gives you three separate APKs. Most modern phones will use the app-arm64-v8a-release.apk version.
3. Signing Your App (Don't Skip This!)
Android won’t let you install a "blank" app for long. To make your app official, you need a digital signature called a Keystore.
- Generate the key: Use the keytool command in your terminal to create a .jks file.
- Reference it: Create a key.properties file in your android/ folder to store your passwords.
- Update Gradle: Configure your android/app/build.gradle to use these credentials during the build process.
Pro Tip: Never, ever upload your key.properties or .jks file to GitHub. Add them to your .gitignore immediately.
4. APK vs. App Bundle (AAB): Which one do you need?
- Use APK for direct sharing (WhatsApp, Google Drive, or Slack).
- Use AAB (flutter build appbundle) for the Google Play Store. Google now requires AABs because they allow the store to generate the smallest possible APK for every specific user.
5. Final Checklist Before You Share
- Change the App Name: Update the android:label in your AndroidManifest.xml so it doesn't just say "Flutter App" on the home screen.
- Update the Package Name: Change com.example.yourapp to something unique like com.yourname.appname.
- Add an Icon: Use the flutter_launcher_icons package to replace the default Flutter logo with your own branding.
Summary Table: Your Build Toolkit
| Goal | Command | Output |
|---|---|---|
| Quick Test | flutter build apk | Fat APK |
| Small File | flutter build apk --split-per-abi | Multiple ABI-specific APKs |
| Play Store | flutter build appbundle | .aab file |
| Clean Start | flutter clean | Clears old build files |
Top comments (0)