How to generate a Google Play upload key and keystore for a Flutter app in Android Studio?

Viewed 2185

I'm trying to deploy my Flutter app to Android. According to the Flutter documentation we have to sign our apps. The first step is to create an upload keystore. There are apparently two ways to do this.

The first method uses Android Studio. The instructions say:

In the menu bar, click Build > Generate Signed Bundle/APK.

Here's a screenshot of Build in Bumblebee 2021.1.1:

enter image description here

Where is Generate Signed Bundle/APK?

I clicked Build > Flutter > Build App Bundle. This ran for awhile and finished without error messages.

The second method uses the CLI. You enter this (on a Mac or Linux):

keytool -genkey -v -keystore ~/upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload

That prompted me for a keystore password. What is that and where do I get one?

I'm supposed to see a upload-keystore.jks file in my home directory. Does this mean in my project's home directory or my user home directory? I don't see that file.

Next, I'm told to

Create a file named [project]/android/key.properties that contains a reference to your keystore:

storePassword=<password from previous step>
keyPassword=<password from previous step>
keyAlias=upload
storeFile=<location of the key store file, such as /Users/<user name>/upload-keystore.jks>

What password from what previous step? And where is the key store file located?

I apologize if this is all obvious to Android users. I've always used iPhones. I bought my first Android phone yesterday and this is completely baffling to me.

1 Answers

Thank you @ישו אוהב אותך. The mistake is that when you run

keytool -genkey -v -keystore ~/upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload

it prompts you: Enter keystore password: It should say Create new keystore password or Enter new keystore password.

I made up a unique new password swordfish and entered it. I was prompted for my name and address and then told:

Warning:
The JKS keystore uses a proprietary format. It is recommended to migrate to PKCS12 which is an industry standard format using "keytool -importkeystore -srckeystore /Users/TDK/upload-keystore.jks -destkeystore /Users/TDK/upload-keystore.jks -deststoretype pkcs12".

So apparently there's a second item that needs to be updated in the documentation.

I ran the new command and now I see a file upload-keystore.jks in my user home directory (not in my project home directory).

I'll post a ticket with Flutter the make these two updates.

Related