Here in this article we will look at the procedure of publishing a Python Kivy based Android application which we built using the buildozer tool in our article “How to build and deploy a Python kivy application for Android device using buildozer“. Publishing an application into Google Playstore requires us to register with one time charge of $25. Once registered we will be able to publish any number of applications.
Lets look at the high level tasks that are required to be carried to make our application eligible for publishing in Google Playstore.
- Build a release apk
- Create a keystore
- Sign the release apk using the keystore
- zipalign the apk
- Publish the apk to Google Playstore
Step1: Build a release apk
In continuation to our article “How to build and deploy a Python kivy application for Android device using buildozer” where we have built an apk using debug and tested it. Here we need to build the apk now in release mode with the below step.
[admin@fed31 ~]$ buildozer -v android release
Step2: Create a keystore
Here we are using the keytool command line to generate a keystore with our personal certificate as shown below.
[admin@fed31 ~]$ keytool -genkey -v -keystore ~/keystores/googleplay.keystore -alias googleplay -sigalg SHA256withRSA -keyalg RSA -keysize 2048 -validity 10000 Enter keystore password: Re-enter new password: What is your first and last name? [Unknown]: Sudhir Bhoga What is the name of your organizational unit? [Unknown]: stack What is the name of your organization? [Unknown]: stack What is the name of your City or Locality? [Unknown]: mumbai What is the name of your State or Province? [Unknown]: maharashtra What is the two-letter country code for this unit? [Unknown]: in Is CN=Sudhir Bhoga, OU=stack, O=stack, L=mumbai, ST=maharashtra, C=in correct? [no]: yes Generating 2,048 bit RSA key pair and self-signed certificate (SHA256withRSA) with a validity of 10,000 days for: CN=Sudhir Bhoga, OU=stack, O=stack, L=mumbai, ST=maharashtra, C=in Enter key password for (RETURN if same as keystore password): [Storing /home/admin/keystores/googleplay.keystore] 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 /home/admin/keystores/googleplay.keystore -destkeystore /home/admin/keystores/googleplay.keystore -deststoretype pkcs12".
Let’s convert our jks keystore to pkcs12 format with below command which is an industry standard format.
[admin@fed31 ~]$ keytool -importkeystore -srckeystore /home/admin/keystores/googleplay.keystore -destkeystore /home/admin/keystores/googleplay.keystore -deststoretype pkcs12 Enter source keystore password: Entry for alias googleplay successfully imported. Import command completed: 1 entries successfully imported, 0 entries failed or cancelled Warning: Migrated "/home/admin/keystores/googleplay.keystore" to Non JKS/JCEKS. The JKS keystore is backed up as "/home/admin/keystores/googleplay.keystore.old".
We can validate our new personal certificate with the below list command.
[admin@fed31 keystores]$ /usr/bin/keytool -list -keystore googleplay.keystore -alias googleplay -v -storepass xxx Enter keystore password: Alias name: googleplay Creation date: Jul 16, 2020 Entry type: PrivateKeyEntry Certificate chain length: 1 Certificate: Owner: CN=Sudhir Bhoga, OU=stack, O=stack, L=mumbai, ST=maharashtra, C=in Issuer: CN=Sudhir Bhoga, OU=stack, O=stack, L=mumbai, ST=maharashtra, C=in Serial number: 30930d01 Valid from: Thu Jul 16 17:29:24 IST 2020 until: Mon Dec 02 17:29:24 IST 2047
Step3: Sign the release apk using the keystore
We can used the jarsigner which comes with any Java JDK package installed on the server. Here is the below command wherein we are siging our release apk using the keystore and our personal certificate with alias ‘googleplay’.
[admin@fed31 bin]$ jarsigner -keystore /home/admin/keystores/googleplay.keystore LoveCalculator-0.1-arm64-v8a-release-unsigned.apk googleplay Enter Passphrase for keystore: jar signed. Warning: The signer's certificate is self-signed.
Step4: zipalign the apk
zipalign is an archive alignment tool that provides important optimization to Android application (ie. .apk) file.
[admin@fed31 bin]$ /home/admin/Android/Sdk/build-tools/30.0.1/zipalign -v 4 LoveCalculator-0.1-arm64-v8a-release-unsigned.apk LoveCalculator-0.1-arm64-v8a-release-optimized.apk Verifying alignment of ./bin/LoveCalculator-0.1-arm64-v8a-release-optimized.apk (4)... 49 AndroidManifest.xml (OK - compressed) 1159 META-INF/CERT.RSA (OK - compressed) 2302 META-INF/CERT.SF (OK - compressed) 4040 META-INF/MANIFEST.MF (OK - compressed) 5748 assets/private.mp3 (OK) 25863427 classes.dex (OK - compressed) 25920988 lib/arm64-v8a/libSDL2.so (OK - compressed) 26407813 lib/arm64-v8a/libSDL2_image.so (OK - compressed) 26879515 lib/arm64-v8a/libSDL2_mixer.so (OK - compressed) 27040503 lib/arm64-v8a/libSDL2_ttf.so (OK - compressed) ... 32350448 res/layout/project_chooser.xml (OK - compressed) 32350850 res/layout/project_empty.xml (OK - compressed) 32351172 resources.arsc (OK) Verification succesful
With this step we have successfully optimized our release apk and now its ready for uploading and publishing to Google Playstore.
Step5: Publish the apk to Google Playstore
Publishing your application using Google Play console is straight forward. You need to create your application upload your apk under App releases section wherein we can publish our application intially using the Internal test track, Closed track and then push it for Production track release.
We also need to answer a few questionnaire related to our application under Store presence – Content rating, App Content and Pricing distribution section. Please answer them accurately as once you submit the application it will be going for Google review and might get rejected if not answered appropriately.
Once the application is submitted, it will take approximately 4 – 5 working days for google to review it and make the application available in Google Playstore.
Here is my first Python Kivy based android application ‘Lovecalculator‘ that i launched in Google Playstore. Take a look at it and provide your feedback. Even though its really a very basic application it has made me learn a lot of stuff in journey of building an application, resolving issues, fixing some code issues and making it available for public.
Application – https://play.google.com/store/apps/details?id=org.stack.lovecalculator
Hope you enjoyed reading this article. Thank you..