user2915097
user2915097

Reputation: 32176

How to build a kivy application using buildozer and the latest kivy?

Using buildozer I have successfully built and run an Android application. Buildozer uses kivy-stable (1.7)

How do I build a kivy application using the latest kivy 1.8 ?

I noticed at https://github.com/kivy/python-for-android/blob/master/recipes/kivy/recipe.sh the lines

VERSION_kivy=${VERSION_kivy:-stable}
URL_kivy=https://github.com/kivy/kivy/zipball/$VERSION_kivy/kivy-$VERSION_kivy.zip

Does this mean that only the kivy-stable version can be used with buildozer ?

Thanks

Upvotes: 9

Views: 3286

Answers (4)

forDeFan
forDeFan

Reputation: 59

Basically - you specify build related things in your buildozer.spec file. Detailed how to - available on project page: https://buildozer.readthedocs.io/en/latest/quickstart.html#init-and-build-for-android

In buildozer.spec you can define:

Requirements needed to build/ compile your project like:

# (list) Application requirements
# comma separated e.g. requirements = sqlite3,kivy
requirements =python3,kivy,kivymd==0.104.2,pillow==9.1.0,sqlite3

You shouldn't forget about Android permissions if needed for example:

# (list) Permissions
android.permissions = 
READ_EXTERNAL_STORAGE,WRITE_EXTERNAL_STORAGE

Last thing in the specs is to define architecture for compiled file. For example:

# (int) Target Android API, should be as high as possible.
android.api = 30

And:

# (list) The Android archs to build for, choices: armeabi-v7a, arm64-v8a, x86, x86_64
android.archs = armeabi-v7a, x86

Then terminal command to buildozer to compile:

$ buildozer -v android debug

You will end up with *.apk file that can be used on physical device (copy to the device, grant permissions to the file on the physical device) or in Android emulator (i.e. GenyMotion -> https://www.geeksforgeeks.org/how-to-set-up-an-emulator-for-vscode/).

If any troubles in build or live debugging you can connect to the emulator with adb, like:

$ adb logcat YOUR_DEVICE_IP > log.txt

Upvotes: 0

Raghav Bharathi
Raghav Bharathi

Reputation: 107

Google Colab!!!

go to this website: https://colab.research.google.com/

Step 1 : Create a new Note Book

Step 2 : add a new codein top left corner

Step 3:add your main python file and kv file

enter image description here

Note: Make sure that your notebook is connected to runtime enter image description here

Step 4:Copy and paste these codes in spreate code cells

!pip install buildozer

.

!pip install cython==0.29.19

.

!sudo apt-get install -y \
python3-pip \
build-essential \
git \
python3 \
python3-dev \
ffmpeg \
libsdl2-dev \
libsdl2-image-dev \
libsdl2-mixer-dev \
libsdl2-ttf-dev \
libportmidi-dev \
libswscale-dev \
libavformat-dev \
libavcodec-dev \
zlib1g-dev

.

!sudo apt-get install -y \
libgstreamer1.0 \
gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good

.

!sudo apt-get install build-essential libsqlite3-dev sqlite3 bzip2 libbz2-dev zlib1g-dev libssl-dev openssl libgdbm-dev libgdbm-compat-dev liblzma-dev libreadline-dev libncursesw5-dev libffi-dev uuid-dev libffi6

.

!sudo apt-get install libffi-dev

.

!buildozer init

.

Make sure to rename your python file as main.py and also upload all the images used in the programe(if used)

navigate to builder.spec file

enter image description here

uncomment and comment these following lines

add __version__ = 0.1 at the top of your main.py

Then

add these Code

!sudo apt install build-essential autoconf libtool

.

pip install --user -U colorama

.

pip install libtool

.

pip install testcase-automaker

.

pip install autoconf

Finally

add this code ... This will build the apk

!buildozer -v android debug

This Worked for me Hope this will work for all

Upvotes: 1

Fedorov7890
Fedorov7890

Reputation: 1255

Now (as on January, 2020) there is an easier option: just specify version in buildozer.spec, e.g.:

requirements = python3,kivy==2.0.0rc1

Upvotes: 1

inclement
inclement

Reputation: 29488

I can't remember if buildozer has a switch to use kivy master (1.8 is unreleased), but you can certainly make it work. Here's a few instructions assuming your shell is something bash-like.

First, create your own local kivy repository:

git clone https://github.com/kivy/kivy.git

Second, export the environment variable P4A_kivy_DIR to point at this directory. If this variable exists, python-for-android (including the one downloaded and used by buildozer) will use that directory to build kivy.

export P4A_kivy_DIR="$PWD/kivy$
echo $P4A_kivy_DIR

The second line should print out the directory of your newly cloned kivy.

You can then run buildozer. You might need to first delete the .buildozer file in your app dir, or more specifically some of the python-for-android components - easiest is just to do

rm -rf /path/to/your/app/.buildozer/android/platform/python-for-android

After that, just run buildozer and the python-for-android component should use your copy of kivy master.

If you want this behaviour to automatically work every time, you could put the export line in your .bashrc or some other suitable shell setup file. If you don't do this, you'll need to run the export line every time you create or replace a .buildozer directory.

Upvotes: 5

Related Questions