Build & Release

Hướng dẫn build và publish VieLang Mobile lên Google Play Store và Apple App Store.

Build & Release

Hướng dẫn build app production và upload lên Google Play StoreApple App Store.

Chuẩn bị

  • Bundle đã tạo trong Mobile Center
  • configs.json đã tải về và đặt đúng vị trí
  • Signing keys đã chuẩn bị

Quan trọng: Không sửa thủ công configs.json — luôn tải lại từ Mobile Center khi cần thay đổi cấu hình.


Build Android

Bước 1: Tạo signing key

keytool -genkey -v \ -keystore ~/vielang-release.keystore \ -alias vielang \ -keyalg RSA -keysize 2048 \ -validity 10000

Bước 2: Cấu hình signing

Tạo file android/key.properties:

storePassword=YOUR_STORE_PASSWORD keyPassword=YOUR_KEY_PASSWORD keyAlias=vielang storeFile=/Users/yourname/vielang-release.keystore

Bảo mật: Thêm key.properties vào .gitignore.

Cập nhật 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 } } }

Bước 3: Build

# App Bundle (khuyến nghị cho Google Play) flutter build appbundle \ --no-tree-shake-icons \ --dart-define-from-file configs.json # Output: build/app/outputs/bundle/release/app-release.aab # APK (nếu cần) flutter build apk \ --no-tree-shake-icons \ --dart-define-from-file configs.json \ --split-per-abi

Bước 4: Upload lên Google Play

  1. Google Play Console → App của bạn
  2. ReleaseProductionCreate new release
  3. Upload file .aab
  4. Điền release notes
  5. Submit for review

Build iOS

Yêu cầu

  • macOS với Xcode 15+
  • Apple Developer Account ($99/năm)
  • Provisioning profiles và certificates

Bước 1: Cấu hình Xcode

open ios/Runner.xcworkspace

Trong Xcode:

  1. RunnerSigning & Capabilities
  2. Chọn Team (Apple Developer Account)
  3. Bundle Identifier: com.yourcompany.app
  4. Đảm bảo Automatically manage signing được bật

Bước 2: Build

flutter build ipa \ --no-tree-shake-icons \ --dart-define-from-file configs.json # Output: build/ios/ipa/YOUR_APP.ipa

Bước 3: Upload lên App Store

Dùng Transporter (macOS):

  1. Tải Transporter từ App Store
  2. Drag & drop file .ipa
  3. Click Deliver

Dùng xcrun:

xcrun altool --upload-app \ --type ios \ --file "build/ios/ipa/YOUR_APP.ipa" \ --username "your@apple.id" \ --password "app-specific-password"

Bước 4: Submit trên App Store Connect

  1. App Store Connect
  2. App của bạn → TestFlight (test) hoặc App Store (production)
  3. Chọn build vừa upload
  4. Submit for Review

CI/CD với GitHub Actions

.github/workflows/release.yml:

name: Release on: push: tags: ['v*'] jobs: build-android: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: subosito/flutter-action@v2 with: flutter-version: '3.29.0' - name: Write configs run: echo '${{ secrets.CONFIGS_JSON }}' > configs.json - name: Write keystore run: | echo '${{ secrets.KEYSTORE_BASE64 }}' | base64 -d > android/app/release.keystore echo 'storeFile=release.keystore' > android/key.properties echo 'storePassword=${{ secrets.KEY_STORE_PASSWORD }}' >> android/key.properties echo 'keyAlias=${{ secrets.KEY_ALIAS }}' >> android/key.properties echo 'keyPassword=${{ secrets.KEY_PASSWORD }}' >> android/key.properties - run: flutter pub get - run: flutter build appbundle --no-tree-shake-icons --dart-define-from-file configs.json - uses: actions/upload-artifact@v4 with: name: android-release path: build/app/outputs/bundle/release/app-release.aab

Build Flags quan trọng

FlagLý do bắt buộc
--dart-define-from-file configs.jsonNạp cấu hình backend, OAuth2, app secret
--no-tree-shake-iconsGiữ lại icon font cho notification icons

Checklist trước khi release

  • configs.json đã tải mới nhất từ Mobile Center
  • Version code và version name đã cập nhật trong pubspec.yaml
  • Icon và splash screen đã thay thế
  • Push notification đã test
  • OAuth2 đã test (nếu dùng)
  • Deep link QR code đã test
  • Build thành công không warning
  • Test trên thiết bị thật (cả Android và iOS)