在 Android Studio 中 Build APK/AAB 並 Deploy 到 Google Play Store 的完整流程如下:
📌 步驟 1:生成簽署金鑰(Signing Key)
Google Play 要求所有應用必須經過 簽署(Signing),確保應用來源可信。
1.1 使用 Android Studio 生成簽署金鑰
- 選單 → Build → Generate
Signed Bundle / APK
- 選擇 Android
App Bundle (AAB)(推薦,Google Play 優先支援)或 APK。
- 點擊 Create
new... 生成新金鑰。
- 填寫金鑰資訊(務必妥善保存!):
- Key store path:選擇儲存位置(建議放專案根目錄的 keystore 資料夾)。
- Password:設定金鑰庫密碼。
- Alias:金鑰別名(例如 upload_key)。
- Validity (years):建議 25 年以上(Google Play 要求至少 2033 年後到期)。
- Certificate:填寫開發者資訊(姓名、組織等)。
- 點擊 OK 生成 .jks 檔案(Java Key Store)。
1.2 設定 Gradle 自動簽署
在 app/build.gradle 中加入簽署配置:
gradle
复制
android {
signingConfigs
{
release {
storeFile file("keystore/your_keystore.jks") // 金鑰路徑
storePassword "your_password"
keyAlias "upload_key"
keyPassword "your_key_password"
}
}
buildTypes
{
release {
signingConfig signingConfigs.release
minifyEnabled true // 啟用混淆
shrinkResources true // 移除未用資源
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),
'proguard-rules.pro'
}
}
}
📌 步驟 2:生成 Release 版本 AAB/APK
2.1 生成 Android App Bundle
(AAB)
- 選單 → Build → Generate
Signed Bundle / APK
- 選擇 Android
App Bundle (AAB)(Google Play 推薦格式)。
- 選擇剛剛建立的簽署金鑰,輸入密碼。
- 點擊 Next,選擇 release 版本。
- 完成後,AAB 檔案會生成在 app/release/ 目錄下(例如 app-release.aab)。
2.2 或生成 APK(較舊方式)
- 選單 → Build → Generate
Signed Bundle / APK
- 選擇 APK。
- 後續步驟與 AAB
相同,生成檔案為 app-release.apk。
📌 步驟 3:上傳至 Google Play
Console
3.1 準備 Google Play 開發者帳號
3.2 上傳 AAB/APK
- 進入 Google
Play Console → 選擇你的應用。
- 左側選單
→ Release → Production(正式版)或 Internal
testing(內部測試)。
- 點擊 Create
new release:
- 上傳
AAB/APK 檔案。
- 填寫 Release
notes(版本更新說明)。
- 點擊 Save → Review
release(檢查無誤後提交審核)。
3.3 設定應用詳細資訊(首次上架)
- Store Listing:填寫應用描述、螢幕截圖、圖示等。
- Content Rating:完成內容分級問卷。
- App Content:提交隱私權政策(如應用需要權限)。
- Pricing & Distribution:選擇免費或付費,並選擇上架國家。
📌 步驟 4:提交審核並發布
- 返回 Release 頁面,確認資訊無誤後點擊 Start rollout to Production。
- Google Play 團隊會進行審核(通常 幾小時到幾天,首次上架可能較久)。
- 審核通過後,應用會自動發布至 Google Play!
🚀 最佳實踐
- 使用 AAB 格式:Google
Play 推薦,可減少用戶下載大小。
- 啟用 App
Signing by Google Play:讓 Google 管理簽署金鑰,避免遺失。
- 測試階段使用
Internal/Closed Testing:先讓小部分用戶測試,再正式發布。
- 監控崩潰報告:整合
Firebase Crashlytics 追蹤錯誤。
完成後,你的應用就會出現在 Google Play 商店供用戶下載!🎉