Sign inSign up

baterflyrity/buildozer

By baterflyrity

•Updated about 3 years ago

Build python apps for Android and iOS with single command. Modern build of official repository.

Image
1

338

baterflyrity/buildozer repository overview

Modern build of official buildozer repository⁠ (see for help). All tags correspond to releases⁠.

⁠Buildozer

Tests Android iOS Coverage Status Backers on Open Collective Sponsors on Open Collective

Buildozer is a tool for creating application packages easily.

The goal is to have one "buildozer.spec" file in your app directory, describing your application requirements and settings such as title, icon, included modules etc. Buildozer will use that spec to create a package for Android, iOS, Windows, OSX and/or Linux.

Buildozer currently supports packaging for Android via the python-for-android⁠ project, and for iOS via the kivy-ios project. iOS and OSX are still under work.

For Android, buildozer will automatically download and prepare the build dependencies. For more information, see Android-SDK-NDK-Information⁠. Note that only Python 3 is supported.

Note that this tool has nothing to do with the eponymous online build service buildozer.io⁠.

⁠Example of Android python application

Create directories layout:

/path/to/project/                    
├── cache/            
└── sources/          
    ├── main.py       
    └── buildozer.spec

Write some code (e.g. using Kivy) into main.py:

from kivy.lang import Builder

from kivymd.app import MDApp


KV = """
Screen:

    MDToolbar:
        title: "My firt app"
        elevation: 10
        md_bg_color: app.theme_cls.primary_color
        left_action_items: [["menu", lambda x: x]]
        pos_hint: {"top": 1}

    MDRaisedButton:
        text: "Hello World"
        pos_hint: {"center_x": .5, "center_y": .5}
"""


class HelloWorld(MDApp):
    def build(self):
        return Builder.load_string(KV)


HelloWorld().run()

Edit buildozer.spec according to your application:

[app]

# (str) Title of your application
title = Android3Test1

# (str) Package name
package.name = android_3_test_1

# (str) Package domain (needed for android/ios packaging)
package.domain = com.baterflyrity

# (str) Source code where the main.py live
source.dir = .

# (list) Source files to include (let empty to include all the files)
source.include_exts = py,png,jpg,jpeg,ttf

# (list) Application version
version = 0.0.1

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

# (str) Supported orientation (one of landscape, sensorLandscape, portrait or all)
orientation = portrait

# (bool) Indicate if the application should be fullscreen or not
fullscreen = 1

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

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

# (int) Minimum API your APK will support.
android.minapi = 21

# (str) Android NDK version to use
android.ndk = 25c

# (bool) If True, then skip trying to update the Android sdk
# This can be useful to avoid excess Internet downloads or save time
# when an update is due and you just want to test/build your package
android.skip_update = False

# (bool) If True, then automatically accept SDK license
# agreements. This is intended for automation only. If set to False,
# the default, you will be shown the license when first running
# buildozer.
android.accept_sdk_license = True

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

[buildozer]

# (int) Log level (0 = error only, 1 = info, 2 = debug (with command output))
log_level = 2

# (int) Display warning if buildozer is run as root (0 = False, 1 = True)
warn_on_root = 0

# (str) Path to build artifact storage, absolute or relative to spec file
build_dir = ./.buildozer

# (str) Path to build output (i.e. .apk, .ipa) storage
bin_dir = ./bin

Build Android apk:

docker run -it --rm --name buildozer -v "/path/to/project/cache/":/home/user/.buildozer -v "/path/to/project/sources/":/home/user/hostcwd baterflyrity/buildozer android debug

Tag summary

Content type

Image

Digest

sha256:869bb56fa…

Size

572.9 MB

Last updated

about 3 years ago

docker pull baterflyrity/buildozer