Skip to content

Instantly share code, notes, and snippets.

@Guhan-SenSam
Last active February 9, 2024 11:15
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Guhan-SenSam/fa4ed215ef3419e7b3154de5cb71f641 to your computer and use it in GitHub Desktop.
Save Guhan-SenSam/fa4ed215ef3419e7b3154de5cb71f641 to your computer and use it in GitHub Desktop.
Creating A Release AAB

In this gist I will explain what are all the steps that I followed in order to generate a signed version of my .aab.

Note: This signing process only works on Ubuntu and only works in a single terminal. YOU MUST COMPLETE ALL THE STEPS IN A SINGLE TERMINAL.DO NOT CLOSE THE TERMINAL IN ANY STEPS IN BETWEEN.

  1. Open any directory in your terminal(I prefer the documents directory).
  2. Now type mkdir -p ~/keystores/. This will create a folder in your home directory witht the name keystore. Keep this folder safe as you need it to update your app later down the line
  3. Now run this command keytool -genkey -v -keystore ~/keystores/<your-new-key>.keystore -alias <your-key-alias> -keyalg RSA -keysize 2048 -validity 10000. Here replace <your-new-key> with the name of your keystore. Replace <your-key-alias> with the name of your key(typically your app name) Set the validity to whatever you want. It represents the number of days your key will be valid. I would recommend setting it to the number of days in 10 years. So for example a command would be keytool -genkey -v -keystore ~/keystores/mykeystore.keystore -alias picdf -keyalg RSA -keysize 2048 -validity 3650

Note: PLEASE USE YOUR OWN PASSWORDS AND NAMES FOR YOUR KEYSTORES.THESE NAMES ARE JUST FOR DEMO PURPOSES. USE ONLY ENGLISH CHARACTERS TO AVOID PROBLEMS

  1. You will then be asked a series of questions such as your name and company etc. Type whatever you want in these fields as they only are important for major companies and doesn't really affect the key. At the end you will be asked for a keystore password and for a key password. Type both of these password the same(or else the next step fails) and keep the password safe.
  2. Now we need to migrate the key to a PKCS12 based key. Execute this command keytool -importkeystore -srckeystore ~/keystores/<your-new-key>.keystore -destkeystore ~/keystores/<your-new-key>.keystore -deststoretype pkcs12 replace your-new-key with the name of the key that you entered in step 3. You will also be asked for your password again. So if I continue my example, my command would look like keytool -importkeystore -srckeystore ~/keystores/mykeystore.keystore -destkeystore ~/keystores/mykeystore.keystore -deststoretype pkcs12
  3. After running the above command if you check your keystore folder you will notice that there is a mykeystore.keystore and a mykeystore.keystore.old. This means that the command worked properly.

7.Now run these commands

export P4A_RELEASE_KEYSTORE=~/keystores/<your-new-key>.keystore
export P4A_RELEASE_KEYSTORE_PASSWD="<your-keystore-password>"
export P4A_RELEASE_KEYALIAS_PASSWD="<your-key-alias-password>"
export P4A_RELEASE_KEYALIAS="<your-key-alias>"

fill in the respective fields properly with your names as needed. For line 2-4 all the values have to be typed in double quotes. Do not type the first value in double quotes. Follow below example carefully.

export P4A_RELEASE_KEYSTORE=~/keystores/mykeystore.keystore
export P4A_RELEASE_KEYSTORE_PASSWD="ILovePandas"
export P4A_RELEASE_KEYALIAS_PASSWD="ILovePandas"
export P4A_RELEASE_KEYALIAS="picdf"

Note: Follow how I have placed the double quotes carefully

  1. Now without closing that terminal, navigate to your working directory(i.e. the directory where you compile with buildozer) and run buildozer -v android release. Make sure u configured the spec file so that releases are made in the .aab format. I would also suggest to rebuild the dependencies before your final compile cause u may never know if some files are missing.
@LucasColas
Copy link

LucasColas commented Aug 4, 2023

Hello,
How do you do when you want to update an app in the store ? You do the same thing ? Except you don't create another key ?

@aliibrahim82
Copy link

aliibrahim82 commented Aug 4, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment