AWolf
AWolf

Reputation: 8970

How do I install Buildozer on Ubuntu to create an Android APK of a Kivy App?

It's not easy to install buildozer on Ubuntu 13.10. I reinstalled Ubuntu several times and now I'd like to share how I installed buildozer.

I got the following errors from buildozer:

  1. ./distribute.sh not found --> no fix found (that's why I reinstalled Ubuntu twice, probably an issue with python installation but I'm not sure)
  2. _add_java_src() fails --> adding the correct Java JDK path fixed it

Upvotes: 5

Views: 19193

Answers (4)

LucioRandy
LucioRandy

Reputation: 230

Check out this video by Erik Sandberg as he explains it really well. Then you will need to go into the bin directory to find your compiled APK. Let me know by adding a comment if this doesn't work.

Upvotes: 1

prosti
prosti

Reputation: 46291

Buildozer itself doesn't depend on any library, and works on Python 2.7 and >= 3.3. Depending on 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.

The official documentation covers more but here is how to do it in Ubuntu 16.04 64-bit:

sudo pip install --upgrade cython==0.21
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install build-essential ccache git libncurses5:i386 libstdc++6:i386 libgtk2.0-0:i386 libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libidn11:i386 python2.7 python2.7-dev openjdk-8-jdk unzip zlib1g-dev zlib1g:i386

Upvotes: 0

AWolf
AWolf

Reputation: 8970

The procedure described below was working perfectly for me:

I've installed it in a fresh installation of Ubuntu 13.10 (32bit) inside a virtual machine (VMware player) in Windows 7 (64bit) host system.

I decided to use 32 bit because the VM uses not that much RAM and a 64bit system is not needed. But 64bit Ubuntu will probably also work (not tested). I uploaded the zip archive of the VMWare files to google drive (password in ubuntu for root user alexander is UbuntuBuildozer)

You can find the zip-file here: https://drive.google.com/file/d/0B5m9_RVHCpL-YmxPVnVaYWZyZ2s/edit?usp=sharing

  1. install Python-Kivy (http://kivy.org/docs/installation/installation-linux.html#ubuntu-11-10-or-newer) with

    $ sudo add-apt-repository ppa:kivy-team/kivy

    $ sudo apt-get update

    $ sudo apt-get install python-kivy

  2. install pip, if you haven't got it:

    $ sudo apt-get install python-pip python-dev build-essential

  3. prerequisites for buildozer: zlib, Git, Cython and JDK is required

    $ sudo apt-get install zlib1g-dev git-core cython openjdk-7-jdk

    install Java JDK guide (http://tecadmin.net/install-java-jdk-ubuntu/#)

  4. install buildozer (https://github.com/kivy/buildozer)

    $ sudo pip install buildozer

  5. initialize buildozer and start with debug (just to install Andriod SDK, NDK & ANT - no main.py needed yet, this takes several minutes):

    $ buildozer init

    $ buildozer android debug

  6. If buildozer fails at _add_java_src(): Add JDK path in /home/yourusername/.bashrc - add these lines at the end (important use 1.x JDK and not java-7 path):

    export PATH=$PATH:/usr/lib/jvm/java-1.6.0-openjdk-i386/bin

    export JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk-i386

  7. Now go to your apps main.py and do the following commands:

    $ buildozer init

    (edit buildozer.spec and change your app name and check the versioning on line 28/29 or line 32 --> depends on your main.py code
    see SO answer to Buildozer compiles simple android kivy application, but fails while packaging)

    $ buildozer android debug deploy run

Upvotes: 4

brousch
brousch

Reputation: 1072

Note that you don't actually need Kivy if all you want to do is compile APKs. I use the following script to install only Buildozer on Ubuntu 13.10 64bit.

#!/bin/sh

# Install necessary system packages
sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install -y build-essential git zlib1g-dev python2.7 python2.7-dev libncurses5:i386 libstdc++6:i386 zlib1g:i386 openjdk-7-jdk unzip

# Bootstrap a current Python environment
sudo apt-get remove --purge -y python-virtualenv python-pip python-setuptools
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | sudo python2.7
rm setuptools*.zip
sudo easy_install-2.7 -U pip
sudo pip2.7 install -U virtualenv

# Install current version of Cython
sudo apt-get remove --purge -y cython
sudo pip2.7 install -U cython

# Install Buildozer from master
sudo pip2.7 install -U git+https://github.com/kivy/buildozer.git@master

Upvotes: 2

Related Questions