Build a Mobile Application With the Kivy Python Framework

Build a Mobile Application With the Kivy Python Framework

Installation

Buildozer itself doesn’t depend on any library Python >= 3.3. Depending the platform you want to target, you might need more tools installed. Buildozer tries to give you hints or tries to install few things for you, but it doesn’t cover every situation.
First, install the buildozer project with:
pip3 install --user --upgrade buildozer

Targeting Android

Android on Ubuntu 18.04 (64bit)

(expected to work as well in later version, but only regularly tested in the latest LTS)
sudo apt update
sudo apt install -y git zip unzip openjdk-8-jdk python3-pip autoconf libtool pkg-config zlib1g-dev libncurses5-dev libncursesw5-dev libtinfo5 cmake libffi-dev
pip3 install --user --upgrade cython virtualenv  # the --user should be removed if you do this in a venv

# add the following line at the end of your ~/.bashrc file
export PATH=$PATH:~/.local/bin/

Then, create a new folder and navigate to it in your terminal. Once you’re there, you’ll need to run the following command:
$ buildozer init
This will create a buildozer.spec file that you’ll use to configure your build. For this example, you can edit the first few lines of the spec file as follows:
[app]

# (str) Title of your application
title = KvCalc

# (str) Package name
package.name = kvcalc

# (str) Package domain (needed for android/ios packaging)
package.domain = org.kvcalc
Once those are installed, copy your calculator application into your new folder and rename it to main.py. This is required by buildozer. If you don’t have the file named correctly, then the build will fail.
Now you can run the following command:
$ buildozer -v android debug

The build step takes a long time! On my machine, it took 15 to 20 minutes. Depending on your hardware, it may take even longer, so feel free to grab a cup of coffee or go for a run while you wait. Buildozer will download whatever Android SDK pieces it needs during the build process. If everything goes according to plan, then you’ll have a file named something like kvcalc-0.1-debug.apk in your bin folder.














留言

此網誌的熱門文章

GIMP磨皮小试-圖層,高斯模糊

Tmux 用法

磁力連結(Magnet URI scheme)