I created a key and keystore and signed my apk, following the instructions step by step from the official flutter page.
But when I try to upload it to Google Play Console, I get this error:
"You uploaded an APK or Android App Bundle that was signed in debug mode. You need to sign your APK or Android App Bundle in release mode"
A similar question is asked before, but it did not solve my issue.
Here is the relevant part of my 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'
}
}
Here is the screenshot of my Android Studio versions (Android SDK being red is not relevant.):
My output.json file:
[
{
"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": {
}
}
]
No suggestions seemed to be working. Then, a
flutter clean
and all issues were solved. I could create an apk either through Android Studio or the command line. Thanks to VikaS and Harsha pulikollu
flutter clean
did not work for me either. So I manually signed the apk and it was accepted by Google Play Console. Found the directions here https://developer.android.com/studio/publish/app-signing#sign-manually
To manually sign the apk you need to run the following commands in a terminal o in command prompt in Windows.
1 - Make sure the apk is signed with debug keys:
<build-tools-path>/<sdk-vesion>/apksigner verify --print-certs app-release.apk
(replace "app-release.apk" with your apk filename"
If it is signed with debug keys, the output will be similar to
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 - Run zipalign to align first byte and reduce RAM usage
<build-tools-path>/<sdk-vesion>/zipalign -v -p 4 app-release.apk app-aligned.apk
It will list the files and finish with a Verification succesful
message.
3 - Run appsigner to sign the app:
<build-tools-path>/<sdk-vesion>/apksigner sign --ks <path to .jks file> --out app-signed.apk app-aligned.apk
It will prompt for the keystore password and silently finish the job.
4 - Verify if it is signed with your keys:
<build-tools-path>/<sdk-vesion>/apksigner verify --print-certs app-signed.apk
If it is correctly signed, the output will be similar to the fist step, but instead of "Android Debug" it will output your certificate's data.
This occurs when the apk or android app bundle is signed in debug mode and uploaded.
So Make sure you have release in 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
}
}
as well as just put yourkeystore.jks file in android/app/yourkeystore.jks so that you don't have to mention the full path.
now the path will be
storePassword=yourkeystore
keyPassword=yourkeystore
keyAlias=yourkeystore
storeFile=yourkeystore.jks
这些是在扑扑中找到了build-tools-pathsdkvesion吗
Try
flutter clean
flutter clean command is really helpful in many scenario whenever some absurd behavior is shown by the app.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.