Preconditon
Create virtualenv and use python3.6 version (Tested on python3.6). Refer below command.
virtualenv -p python3.6 buildozerenv3
Installation steps (Refer: https://github.com/kivy/buildozer)
git clone https://github.com/kivy/buildozer.git
$ pwd
/Users/deepak/Documents/coding/python/android/buildozer
$python3 setup.py build
$pip3 install -e
$python3 ./setup.py install
$ buildozer --help | more
# Check configuration tokens
Usage:
buildozer [--profile <name>] [--verbose] [target] <command>...
buildozer --version
Available targets:
ios iOS target, based on kivy-ios project
android Android target, based on python-for-android project
osx OSX target, based on kivy-sdk-packager
Global commands (without target):
appclean Clean the .buildozer folder in the app directory.
distclean Clean the whole Buildozer environment.
help Show the Buildozer help.
init Create a initial buildozer.spec in the current directory
serve Serve the bin directory via SimpleHTTPServer
setdefault Set the default command to run when no arguments are given
version Show the Buildozer version
Buildozer requires main.py as entry point. Below example has this.
Fetch hello world app
$git clone https://github.com/Dirk-Sandberg/KivyHelloWorld.git
$cd KivyHelloWorld/
$ls
main.py
$buildozer init
$ls
buildozer.spec main.py
$ cat buildozer.spec | more
[app]
# (str) Title of your application
title = My Application
# (str) Package name
package.name = myapp
# (str) Package domain (needed for android/ios packaging)
package.domain = org.test
# (str) Source code where the main.py live
source.dir = .
# (list) Source files to include (let empty to include all the files)
source.include_exts = py,png,jpg,kv,atlas
...
$ cat main.py
from kivy.app import App
from kivy.uix.button import Button
class MainApp(App):
def build(self):
return Button(text="Hello World")
MainApp().run()
Enable android Logcat in the Buildozer spec
# (str) Android logcat filters to use
android.logcat_filters = *:S python:D
APT pkg install
deepak@containerd121:~/deepak/neo4j/android/KivyHelloWorld$ sudo apt update
deepak@containerd121:~/deepak/neo4j/android/KivyHelloWorld$ sudo apt install -y git zip openjdk-8-jdk python3-pip autoconf libtool pkg-config zlib1g-dev libncurses5-dev libncursesw5-dev libtinfo5 cmake libffi-dev
deepak@containerd121:~/deepak/neo4j/android/KivyHelloWorld$ pip3 install --user --upgrade Cython virtualenv
Run Buildozer for api creation
Buildozer for api creation
(buildozerenv3) deepak@containerd121:~/deepak/neo4j/android/KivyHelloWorld$ buildozer android debug deploy run
......
WARNING: Received a --sdk argument, but this argument is deprecated and does nothing.
No compiled python is present to zip, skipping.
No setup.py/pyproject.toml used, copying full private data into .apk.
Applying Java source code patches...
Applying patch: src/patches/SDLActivity.java.patch
# Android packaging done!
# APK helloworld-0.1-armeabi-v7a-debug.apk available in the bin directory
# Run '/home/deepak/.buildozer/android/platform/android-sdk/platform-tools/adb devices'
# Cwd None
* daemon not running; starting now at tcp:5037
* daemon started successfully
List of devices attached
# Application pushed.
# Application started.
(buildozerenv3) deepak@containerd121:~/deepak/neo4j/android/KivyHelloWorld$ ls
bin buildozer.spec main.py
(buildozerenv3) deepak@containerd121:~/deepak/neo4j/android/KivyHelloWorld$ ls -ltrh bin
total 13M
-rw-rw-r-- 1 deepak deepak 13M Apr 19 06:51 helloworld-0.1-armeabi-v7a-debug.apk
Copy the APK file to android device and then install it. Below is the output.
Android SDK command line tool at https://developer.android.com/studio/command-line
https://github.com/joaoventura/pybridge
https://www.youtube.com/watch?v=EupAeyL8zAo
https://www.youtube.com/watch?v=kRWtSkIYPFI
https://github.com/HeaTTheatR/KivyMD.git
https://wiki.python.org/moin/Android