Getting started to develop Kivy apps for smartphones using buildozer

There is Kivy in python's cross-platform development library. The detailed mechanism of Kivy itself is set aside (I haven't used it yet), I would like to introduce a rough method to create a package for iOS / Android provided by Kivy.

python-for-android and kivy-ios

python-for-android

This is a project to package Kivy for android. (It seems to be different from the one in Google Code) It seems to be a mechanism to build Python for ARM based on Android SDK + NDK (= hostpytthon) and run the actual application on hostpython.

$ cd python-for-android
$ ./distribute.sh -m "openssl pil kivy"
$ cd dist/default
$ ./build.py --package org.test.touchtracer --name touchtracer --version 1.0 --dir ~/code/kivy/examples/demo/touchtracer debug

The execution itself does not require such a difficult procedure,

That is a little troublesome.

kivy-ios

This is a project to create an xcode project for iOS.

$ ls 
kivyapp <-Here is the Kivy app
$ git clone https://github.com/kivy/kivy-ios
$ ./tools/build-all.sh
$ ./tools/create-xcode-project.sh kivyapp ./kivyapp

The command itself is as simple as python-for-android, and you can easily check the operation of the actual machine, but

I'm worried that I have something like that.

Prepare Android / iOS build environment together with buildozer

Buildozer is a tool that can control the above two projects at once. Eventually

It handles most of the things related to packaging.

Try to install

It is also registered on PyPI, but personally it is better to install it from the source on github. (In stable, android environment construction does not proceed due to various problems)

$ git clone git://github.com/kivy/buildozer
$ cd buildozer
$ python setup.py install

Basically, most of it is done with the buildozer command that is available during installation.

$ buildozer init
$ ls -l
(App source)
buildozer.spec <-Build here/Describe the items required for packaging (app name, iOS App ID, etc.)
$ buildozer android debug <-Packaging apk files for android. The process in the middle is also executed with this command
$ buildozer ios debug <-Ipa packaging for ios. The process in the middle is also executed with this command

It ’s easy, is n’t it?

Since the path of Android SDK and NDK can be described in buildozer.spec, it is possible to use the one that has already been downloaded. You can also set individual variables using the --profile option for detailed builds.

Points to be careful

As mentioned above, you can specify the path of SDK, NDK, etc., but if you execute it without editing anything, it will try to download all. Also, since python-for-android and kivy-ios are downloaded and handled collectively only under specific control, All of the above issues remain.

Still, I recommend it because you can concentrate on developing apps on Kivy unless you use a very unusual Python package.

Bonus

スクリーンショット 2014-12-10 22.39.02.png

This is the result of packaging an app that displays only the Hello world button.

The ipa file has grown brilliantly. On the contrary, I was impressed that the Apk file was unexpectedly small.

Recommended Posts

Getting started to develop Kivy apps for smartphones using buildozer
Getting Started with Python for PHPer-Classes
Getting Started with Julia for Pythonista
Getting Started with Python for PHPer-Functions
Getting Started with Flask with Azure Web Apps
Getting Started with Python for PHPer-Super Basics
How to use Pylint for PyQt5 apps
Getting started: 30 seconds to Keras Japanese translation
Getting Started with Lisp for Pythonista: Supplement
I want to develop Android apps on Android