Flutter release apk not accepted by Google Play Console
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
You need to select release
option while building APK
For Windows
For Apple
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
How to manually sign apk
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.