Skip to main content


Kivy .APK .AAB | Kivy Python Framework For Mobile App Development

 


https://pysnakeblog.blogspot.com/2022/01/kivy-apk-aab-kivy-python-framework-for.html

What is KIVY?
Kivy is a free and open-source Python library used for developing mobile applications and other multitouch application software with a Natural User Interface.

What is Google Colaboratory?
Google Colaboratory, or "Colab" for short, is a product from Google Research. Colab allows anybody to write and execute arbitrary python code through the browser, and is especially well suited to machine learning, data analysis and education. More technically, Colab is a hosted Jupyter notebook service that requires no setup to use, while providing free access to computing resources including GPUs.

In this tutorial I will show you how to Create KIVY APK / AAB using Google Colab

Yes we can use Google Colab to create Kivy App. The Best part is you can do the same using your tab or a mobile phone and create a Kivy App. And you don't need to download tones of packages which also means not much data is used. And yet you get the same result as a full-fledged computer with good internet speed does.

So lets get started.

To make Python Apk
You need :- main.py (Main Python Script)
font file (.ttf) - Font used by the Script


🥝 Run 1 [Install Buildozer]

!pip install buildozer

🥝 Run 2 [Install Cython Version 0.29.19]

!pip install cython==0.29.19

🥝 Run 3 [Lsb_Release Command Prints Certain Lsb (Linux Standard Base) And Distribution Information.]

!lsb_release -a

🥝 Run 4 [Install Python And Other Libraries]

!sudo apt-get install -y \
    python3-pip \
    build-essential \
    git \
    python3 \
    python3-dev \
    ffmpeg \
    libsdl2-dev \
    libsdl2-image-dev \
    libsdl2-mixer-dev \
    libsdl2-ttf-dev \
    libportmidi-dev \
    libswscale-dev \
    libavformat-dev \
    libavcodec-dev \
    zlib1g-dev 

🥝 Run 5 [Install More Libraries]

*Cannot install these 3 libraries together with the above. It will create an Error.

!sudo apt-get install -y \
    libgstreamer1.0 \
    gstreamer1.0-plugins-base \
    gstreamer1.0-plugins-good

🥝 Run 6 [More Libraries]

!sudo apt-get install build-essential libsqlite3-dev sqlite3 bzip2 libbz2-dev zlib1g-dev libssl-dev openssl libgdbm-dev libgdbm-compat-dev liblzma-dev libreadline-dev libncursesw5-dev libffi-dev uuid-dev libffi6

🥝 Run 7 [Some More Libraries] *Important

!sudo apt-get install libffi-dev
!sudo apt-get install automake
!sudo apt-get install autoconf
!sudo apt-get install libltdl-dev
!sudo apt-get install libtool

🥝 Run 8 [Create Buildozer Spec]

what works: function + python_for_android + wav
Type "y"
Press Refresh Folder at the left
open buildozer.spec file
add "wav" in file used
add "python_for_android" in require


!buildozer init

ADD specifications to buildozer.spec
API List :-
https://source.android.com/setup/start/build-numbers


...
4 title = <YOUR APP NAME>
...
7 package.name= <yourappname>
...
10 package.domain = com.companyname.yourappname
...
16 source.include_exts = wav, ttf
...
39 requirements = kivy, python_for_android, android, jnius, kivmob
...
52 icon.filename = position.png
...
55 orientation = landscape
...
78 fullscreen = 1
...
88 android.permissions = INTERNET, ACCESS_NETWORK_STATE, WAKE_LOCK
...
91 android.api = 30
...
94 android.minapi = 21
...
97 android.sdk = 24
...
100 android.ndk = 19b
...
159 android.gradle_dependencies = 'com.google.firebase:firebase-ads:10.2.0'
...
203 android.wakelock = True
...
206 android.meta_data = com.google.android.gms.ads.APPLICATION_ID=ca-app-pub-3940256099942544~3347511713
...
236 p4a.branch = master
...

# For test ads, use application ID ca-app-pub-3940256099942544~3347511713
android.meta_data = com.google.android.gms.ads.APPLICATION_ID={ADMOB_APP_ID_HERE}

🥝 Run 9 [Adding Admob To Kivy] [install kivmob for Admob]

*Note If you don't wish to use Admob then Skip this step


!pip install kivmob

🔴 🥝 Run 10 A [Create App As Debug Mode]

If you wish to test it on your phone run this line.
Type"y"
This will take upto 15 ~ 20 minutes or more. upto 35 minutes.


!buildozer -v android debug

🟢 🥝 Run 10 B [Create App As Release Mode]

If you wish to upload in google play store run this line.
Type"y"
This will take upto 15 ~ 20 minutes or more.


!buildozer -v android release

🔵 🥝 Run 11 [Clean Previous App Built]

Cleaning old settings.


!buildozer android clean

🥝 Run 12 [Check If "keystore maker" is installed and running. It is called "keytool"]

!keytool -h

🥝 Run 13 [Create Folder Named Keystores]

!mkdir keystores

🥝 Run 14 [Creating KeyStore]

!keytool -genkey -v -keystore keystores/kivyapp.keystore -alias kivyapp -sigalg SHA256withRSA -keyalg RSA -keysize 2048 -validity 10000

🥝 Run 15 [Convert jks keystore to pkcs12 format keystore which is an industry standard format.]

!keytool -importkeystore -srckeystore keystores/kivyapp.keystore -destkeystore keystores/kivyapp.keystore -deststoretype pkcs12

🥝 Run 16 [Validate our new personal certificate] Password I am using 123456789

*replace 123456789 with your own password


!keytool -list -keystore keystores/kivyapp.keystore -alias kivyapp -v -storepass 123456789

🥝 Run 17 [Get File Path of your APK using windows CMD command line]

!cd bin && echo -ne "bin/"&&dir

🥝 Run 18 [Sign the release apk using the keystore]

!jarsigner -keystore keystores/kivyapp.keystore < YOUR APK > kivyapp


!jarsigner -keystore keystores/kivyapp.keystore <YOUR APK PATH> kivyapp

🥝 Run 19 [Install Android SDK]

Reason:- We need zipalign tool found in Android SDK
for that Install android-sdk
It will take few seconds to install unlike windows


!sudo apt update && sudo apt install android-sdk

🥝 Run 20 [Check if zipalign is installed & running]

!zipalign -h

🥝 Run 21 [Get File Path of your APK again using windows CMD command line]

!cd bin && echo -ne "bin/"&&dir

🥝 Run 22 [zipalign the APK]

zipalign is an archive alignment tool that provides important optimization to Android application (ie. .apk) file.
...
!zipalign -v 4 < YOUR APK-release-unsigned.apk > < YOUR APK-release-optimized.apk >
...
!zipalign -v 4 bin/YOUR-APK-release-unsigned.apk Final-APK-release-optimized.apk


!zipalign -v 4 <YOUR APK PATH> myapp-0.1-armeabi-v7a-release--optimized.apk

 

NOTE DONT FORGET Toooooooooooooooooooooooo......:

  • Download your keystores old & new
  • Remember your keystore password (write it somewhere)
  • Download your unsign apk
  • Download your release apk
  • Download your ICON/sound file/font file if any
  • Download your main.py *IMPORTANT
Because After you close google colab it will not save your work Backup EVERYTHING

:::Dev Info:::

My Name:- Joel D'costa
Git:- Kivy APP Maker
Google Colab:-


Comments



🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍🐍

Popular Posts

Python underline string, Python underline text, Underline python print

Python pip - Installing modules from IDLE (Pyton GUI) for python 3.7

Top 40 Python - String Processing in Python | Working with String in Python

Python Program - When was I born? / Date of Birth / MY BIRTHDAY (using Python3+)

Top 11 Essential Python Tips and Tricks





Subscribe to our Channel


Follow us on Facebook Page

Join our python facebook groups



Join us on Telegram