Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 828
AWolf Avatar asked Apr 11 '14 23:04

AWolf


2 Answers

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

like image 141
AWolf Avatar answered Sep 22 '22 20:09

AWolf


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
like image 32
brousch Avatar answered Sep 25 '22 20:09

brousch