Deployment
Deploy Flutter App
ដំណើរការផ្សព្វផ្សាយ app ទៅ Google Play Store, Apple App Store, និង Web។ Deployment process ខុសគ្នាសម្រាប់ platform នីមួយៗ។
📚 Deployment Overview
Deployment Checklist:
Pre-Deployment Steps
✅ Testing
- Run all tests (unit, widget, integration)
- Test on real devices (iOS & Android)
- Fix all bugs and crashes
✅ Performance
- Optimize images & assets
- Remove debug code
- Check app size
✅ App Store Requirements
- App icon (all sizes)
- Screenshots (multiple devices)
- App description & keywords
- Privacy policy
✅ Legal
- Terms of service
- Privacy policy
- App permissions justification
✅ Build Configuration
- Update version number
- Set release mode
- Configure signing
Platform Comparison:
Platform | Cost | Review Time | Difficulty |
---|---|---|---|
Android (Play Store) | $25 (one-time) | Few hours - 1 day | ⭐ Easy |
iOS (App Store) | $99/year | 1-3 days | ⭐⭐⭐ Hard |
Web | Free (+ hosting) | Instant | ⭐ Easy |
📱 Android Deployment (Complete Guide)
Step 1: Update App Configuration
// android/app/build.gradle
android {
defaultConfig {
applicationId "com.yourcompany.appname" // Unique ID
minSdkVersion 21 // Minimum Android version
targetSdkVersion 34 // Target Android version
versionCode 1 // Increment for each release
versionName "1.0.0" // User-visible version
}
}
Step 2: បង្កើត Keystore (App Signing)
keytool -genkey -v -keystore my-release-key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias my-key-alias
2. Configure Build
បង្កើត android/key.properties
:
storePassword=your_password
keyPassword=your_password
keyAlias=my-key-alias
storeFile=../my-release-key.jks
Step 3: Configure Gradle for Signing
// android/app/build.gradle
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
shrinkResources true
}
}
}
Step 4: Build Release APK/AAB
flutter build apk --release
App Bundle (Recommended for Play Store):
flutter build appbundle --release
# Output: build/app/outputs/bundle/release/app-release.aab
APK vs AAB:
- ✅ AAB (Android App Bundle): Smaller download size, Play Store generates optimized APKs
- ⚠️ APK: Larger file, good for direct distribution
Step 5: Upload to Play Console
- Go to play.google.com/console
- Create new application
- Fill app details (title, description, screenshots)
- Upload AAB file
- Set pricing & distribution
- Submit for review
Required Assets:
- App Icon: 512x512px
- Feature Graphic: 1024x500px
- Screenshots: At least 2 (phone, tablet if supported)
- Privacy Policy URL
- Content Rating questionnaire
🍎 iOS Deployment (Complete Guide)
Prerequisites:
- Mac computer with Xcode
- Apple Developer account ($99/year)
- Physical iOS device for testing
Step 1: Configure App in Xcode
# Open iOS project in Xcode
open ios/Runner.xcworkspace
In Xcode:
- Select Runner project
- General tab → Update Bundle Identifier (unique)
- Update Display Name, Version, Build Number
- Signing & Capabilities → Select Team
- Enable Automatically manage signing
Step 2: Update Info.plist
<!-- ios/Runner/Info.plist -->
<key>CFBundleName</key>
<string>Your App Name</string>
<key>CFBundleDisplayName</key>
<string>Your App</string>
<!-- Add permissions if needed -->
<key>NSCameraUsageDescription</key>
<string>We need camera access to take photos</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>We need photo library access</string>
Step 3: Build Archive
- Build iOS app:
flutter build ios --release
- Open Xcode
- Product → Archive (wait for build to complete)
- Window → Organizer → Archives
- Select archive → Distribute App
- Choose App Store Connect → Upload
- Wait for processing (10-30 minutes)
Step 4: App Store Connect
- Go to appstoreconnect.apple.com
- My Apps → Create New App
- Fill app information:
- App name (30 characters max)
- Primary language
- Bundle ID (must match Xcode)
- SKU (unique identifier)
- Add App Information:
- Screenshots (required sizes)
- Description (up to 4000 characters)
- Keywords
- Support URL
- Marketing URL (optional)
- Privacy Policy URL
- Select build → Submit for Review
Required Screenshots:
- iPhone 6.7" (1290x2796px) - 3-10 screenshots
- iPhone 6.5" (1284x2778px)
- iPhone 5.5" (1242x2208px)
- iPad Pro 12.9" (2048x2732px) - if iPad supported
🌐 Web Deployment
Step 1: Build for Web
# Build web app
flutter build web --release
# Output folder: build/web/
Step 2: Deploy to Hosting
Option 1: Firebase Hosting (Recommended)
# Install Firebase CLI
npm install -g firebase-tools
# Login
firebase login
# Initialize
firebase init hosting
# Deploy
firebase deploy
# Your app: https://your-app.web.app
Option 2: GitHub Pages
# Add to build/web/index.html before </head>
<base href="/repository-name/">
# Build
flutter build web --release --base-href "/repository-name/"
# Push build/web to gh-pages branch
Option 3: Vercel/Netlify
# Just drag & drop build/web folder
# Or connect GitHub repository
🔄 Version Management
# pubspec.yaml
version: 1.0.0+1
# │ │ │ │
# │ │ │ └── Build number (Android versionCode, iOS CFBundleVersion)
# │ │ └───── Patch version (bug fixes)
# │ └──────── Minor version (new features, backwards compatible)
# └─────────── Major version (breaking changes)
# Examples:
# 1.0.0+1 - Initial release
# 1.0.1+2 - Bug fix release
# 1.1.0+3 - New feature release
# 2.0.0+4 - Major update
📊 App Size Optimization
# Analyze app size
flutter build apk --analyze-size
flutter build ios --analyze-size
# Remove unused resources
flutter pub run flutter_native_splash:remove
# Use vector images (SVG) instead of PNG when possible
# Enable code obfuscation (makes reverse engineering harder)
flutter build apk --obfuscate --split-debug-info=build/app/outputs/symbols
🔐 ProGuard (Android Code Minification)
# android/app/proguard-rules.pro
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.** { *; }
-keep class io.flutter.util.** { *; }
-keep class io.flutter.view.** { *; }
-keep class io.flutter.** { *; }
🚀 CI/CD with GitHub Actions
# .github/workflows/deploy.yml
name: Deploy to Stores
on:
push:
tags:
- 'v*'
jobs:
build_android:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.16.0'
- run: flutter pub get
- run: flutter test
- run: flutter build appbundle --release
- name: Upload to Play Store
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJsonPlainText: secrets.PLAY_STORE_JSON
packageName: com.yourapp.package
releaseFiles: build/app/outputs/bundle/release/app-release.aab
track: production
💡 Best Practices:
- ✅ Test on real devices before publishing
- ✅ Use internal testing track first (Play Store)
- ✅ Keep keystore file secure (backup safely!)
- ✅ Write clear release notes for users
- ✅ Respond to user reviews promptly
- ✅ Monitor crash reports (Firebase Crashlytics)
- ✅ Use semantic versioning (major.minor.patch)
⚠️ ចំណាំ: Android deployment ត្រូវការ Google Play Developer account ($25 one-time fee)។ iOS deployment ត្រូវការ Apple Developer account ($99/year) និង Mac computer។
🔐 Security Warnings:
- ❌ NEVER commit keystore files to Git
- ❌ NEVER commit key.properties to Git
- ❌ Don't share keystore password publicly
- ✅ Backup keystore in secure location
- ✅ If you lose keystore, you cannot update your app!
💡 ជំនួយ: សម្រាប់ testing មុន publish ប្រើ Internal Testing track នៅ Play Console។ iOS ប្រើ TestFlight សម្រាប់ beta testing។ Web deployment ងាយបំផុត គ្រាន់តែ upload build/web folder។