[英]Flutter release apk not accepted by Google Play Console
我按照官方 flutter 頁面上的說明一步一步創建了一個密鑰和密鑰庫並簽署了我的 apk。
但是當我嘗試將它上傳到 Google Play Console 時,出現了這個錯誤:
“您上傳了一個在調試模式下簽名的 APK 或 Android App Bundle。您需要在發布模式下簽署您的 APK 或 Android App Bundle”
之前有人問過類似的問題,但沒有解決我的問題。
這是我的 app/build.gradle 的相關部分:
android {
compileSdkVersion 28
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "my.package.name"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
//testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
這是我的 Android Studio 版本的屏幕截圖(Android SDK 為紅色與此無關。):
我的 output.json 文件:
[
{
"outputType": {
"type": "APK"
},
"apkInfo": {
"type": "MAIN",
"splits": [
],
"versionCode": 1,
"versionName": "1.0.0",
"enabled": true,
"outputFile": "app-release.apk",
"fullName": "release",
"baseName": "release"
},
"path": "app-release.apk",
"properties": {
}
}
]
似乎沒有任何建議有效。 然后,一個
撲干凈
並且所有問題都解決了。 我可以通過 Android Studio 或命令行創建一個 apk。 感謝 VikaS 和 Harsha pulikollu
flutter clean
對我也不起作用。 所以我手動簽署了 apk 並被 Google Play Console 接受。 在這里找到方向https://developer.android.com/studio/publish/app-signing#sign-manually
要手動簽署 apk,您需要在 Windows 的命令提示符下的終端 o 中運行以下命令。
1 - 確保使用調試密鑰對 apk 進行簽名:
<build-tools-path>/<sdk-vesion>/apksigner verify --print-certs app-release.apk
(用你的apk文件名替換“app-release.apk”
如果使用調試密鑰簽名,則輸出將類似於
Signer #1 certificate DN: C=US, O=Android, CN=Android Debug
Signer #1 certificate SHA-256 digest: 384cf54f892877ea6d934bbc335bf3aa61b8dd3d89e27feb49c0bc7e62b0bbb7
Signer #1 certificate SHA-1 digest: c7a8384ff8fe2d1e99dbdba45db93180ed53b9ff
Signer #1 certificate MD5 digest: ca13ad2688257283319bf2596f360f8c
2 - 運行 zipalign 以對齊第一個字節並減少 RAM 使用
<build-tools-path>/<sdk-vesion>/zipalign -v -p 4 app-release.apk app-aligned.apk
它將列出文件並以Verification succesful
消息結束。
3 - 運行 appsigner 來簽署應用程序:
<build-tools-path>/<sdk-vesion>/apksigner sign --ks <path to .jks file> --out app-signed.apk app-aligned.apk
它將提示輸入密鑰庫密碼並靜默完成工作。
4 - 驗證它是否使用您的密鑰簽名:
<build-tools-path>/<sdk-vesion>/apksigner verify --print-certs app-signed.apk
如果簽名正確,輸出將類似於第一步,但它會輸出您的證書數據,而不是“Android Debug”。
當 apk 或 android 應用程序包在調試模式下簽名並上傳時,會發生這種情況。
所以請確保您在build.gradle 中有發布
buildTypes {
release {
minifyEnabled true
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.release
}
}
以及只需將yourkeystore.jks文件放在android/app/yourkeystore.jks 中,這樣您就不必提及完整路徑。
現在路徑將是
storePassword=yourkeystore
keyPassword=yourkeystore
keyAlias=yourkeystore
storeFile=yourkeystore.jks
這些是在撲撲中找到了build-tools-pathsdkvesion嗎
嘗試
flutter clean
每當應用程序顯示一些荒謬的行為時,flutter clean 命令在許多情況下都非常有用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.