mzakharo / flutter_with_python_android Goto Github PK
View Code? Open in Web Editor NEWBuild a Flutter APK with a builtin Python Service backend
License: MIT License
Build a Flutter APK with a builtin Python Service backend
License: MIT License
I tried to follow the instructions exactly on a brand new Ubuntu 20.04 LXC container. I believe I've applied the two fixes mentioned at the top (#2612 and #1444).
Here is what I did (as user ubuntu
):
sudo apt update && sudo DEBIAN_FRONTEND=noninteractive apt install -y git zip unzip openjdk-13-jdk python3-pip autoconf libtool pkg-config zlib1g-dev libncurses5-dev libncursesw5-dev libtinfo5 cmake libffi-dev libssl-dev ccache lld
export PATH=$PATH:~/.local/bin
python3 -m pip install --upgrade Cython==0.29.19 virtualenv
python3 -m pip install git+https://github.com/kivy/buildozer.git@c2fcc5d8048cecf52fc4e4d469d9a5e18be81dbc # "fix aar build #1444" commit 2022-07-13
mkdir ~/libapp && cd $_
buildozer init
printf "import time\nwhile True:\n time.sleep(1)\n print('hellow world')\n" >srv.py
perl -p -i -e 's|#?\s*(package.domain)\s*=.*|$1 = org.domain|;' buildozer.spec
perl -p -i -e 's|#?\s*(p4a.bootstrap)\s*=.*|$1 = service_library|;' buildozer.spec
perl -p -i -e 's|#?\s*(android.release_artifact)\s*=.*|$1 = aar|;' buildozer.spec
perl -p -i -e 's|#?\s*(services)\s*=.*|$1 = Srv:srv.py:foreground:sticky|;' buildozer.spec
perl -p -i -e 's|#?\s*(android.archs)\s*=.*|$1 = arm64-v8a, x86|;' buildozer.spec
perl -p -i -e 's|#?\s*(p4a.commit)\s*=.*|$1 = a169f0d124860372055785aaee103de2c4bb2044|;' buildozer.spec # Fixing service_library bootstrap + .aar build. (#2612) 2022-07-11
perl -p -i -e 's|#?\s*(p4a.branch)\s*=.*|$1 = develop|;' buildozer.spec
buildozer android release
Output of cat buildozer.spec |grep -v -e ^# -e ^$
:
[app]
title = My Application
package.name = myapp
package.domain = org.domain
source.dir = .
source.include_exts = py,png,jpg,kv,atlas
version = 0.1
requirements = python3,kivy
orientation = portrait
services = Srv:srv.py:foreground:sticky
osx.python_version = 3
osx.kivy_version = 1.9.1
fullscreen = 0
android.archs = arm64-v8a, x86
android.allow_backup = True
android.release_artifact = aar
p4a.branch = develop
p4a.commit = a169f0d124860372055785aaee103de2c4bb2044
p4a.bootstrap = service_library
ios.kivy_ios_url = https://github.com/kivy/kivy-ios
ios.kivy_ios_branch = master
ios.ios_deploy_url = https://github.com/phonegap/ios-deploy
ios.ios_deploy_branch = 1.10.0
ios.codesign.allowed = false
[buildozer]
log_level = 2
warn_on_root = 1
And last but not least, the log:
ubuntu@fwpoa:~/libapp$ buildozer android release
# Check configuration tokens
# Ensure build layout
# Check configuration tokens
# Read available permissions from api-versions.xml
# Preparing build
# Check requirements for android
# Run 'dpkg --version'
# Cwd None
Debian 'dpkg' package management program version 1.19.7 (amd64).
This is free software; see the GNU General Public License version 2 or
later for copying conditions. There is NO warranty.
# Search for Git (git)
# -> found at /usr/bin/git
# Search for Cython (cython)
# -> found at /home/ubuntu/.local/bin/cython
# Search for Java compiler (javac)
# -> found at /usr/lib/jvm/java-17-openjdk-amd64/bin/javac
# Search for Java keytool (keytool)
# -> found at /usr/lib/jvm/java-17-openjdk-amd64/bin/keytool
# Install platform
# Run 'git clone -b develop --single-branch https://github.com/kivy/python-for-android.git python-for-android'
# Cwd /home/ubuntu/libapp/.buildozer/android/platform
Cloning into 'python-for-android'...
# Run 'git reset --hard a169f0d124860372055785aaee103de2c4bb2044'
# Cwd /home/ubuntu/libapp/.buildozer/android/platform/python-for-android
HEAD is now at a169f0d1 Fixing service_library bootstrap + .aar build. (#2612)
# Run '/usr/bin/python3 -m pip install -q --user \'appdirs\' \'colorama>=0.3.3\' \'jinja2\' \'six\' \'enum34; python_version<"3.4"\' \'sh>=1.10; sys_platform!="nt"\' \'pep517<0.7.0\' \'toml\''
# Cwd None
# Apache ANT found at /home/ubuntu/.buildozer/android/platform/apache-ant-1.9.4
# Android SDK found at /home/ubuntu/.buildozer/android/platform/android-sdk
# Recommended android's NDK version by p4a is: 23b
# Android NDK found at /home/ubuntu/.buildozer/android/platform/android-ndk-r23b
# Installing/updating SDK platform tools if necessary
# Run '/home/ubuntu/.buildozer/android/platform/android-sdk/tools/bin/sdkmanager --sdk_root=/home/ubuntu/.buildozer/android/platform/android-sdk platform-tools'
# Cwd /home/ubuntu/.buildozer/android/platform/android-sdk
[=======================================] 100% Computing updates...
# Run '/home/ubuntu/.buildozer/android/platform/android-sdk/tools/bin/sdkmanager --sdk_root=/home/ubuntu/.buildozer/android/platform/android-sdk --update'
# Cwd /home/ubuntu/.buildozer/android/platform/android-sdk
[=======================================] 100% Computing updates...
# Updating SDK build tools if necessary
# Run '/home/ubuntu/.buildozer/android/platform/android-sdk/tools/bin/sdkmanager --sdk_root=/home/ubuntu/.buildozer/android/platform/android-sdk --list'
# Cwd /home/ubuntu/.buildozer/android/platform/android-sdk
Installed packages:=====================] 100% Computing updates...
Path | Version | Description | Location
------- | ------- | ------- | -------
build-tools;33.0.0 | 33.0.0 | Android SDK Build-Tools 33 | build-tools/33.0.0/
platform-tools | 33.0.2 | Android SDK Platform-Tools | platform-tools/
platforms;android-27 | 3 | Android SDK Platform 27 | platforms/android-27/
tools | 2.0.0 | Android SDK Tools 2 | tools/
Available Packages:
Path | Version | Description
------- | ------- | -------
add-ons;addon-google_apis-google-15 | 3 | Google APIs
<----cut---->
system-images;android-Tiramisu;google-tv;x86 | 3 | Google TV Intel x86 Atom System Image
system-images;android-TiramisuPrivacySandbox;google_apis_playstore;arm64-v8a | 6 | Google Play ARM 64 v8a System Image
system-images;android-TiramisuPrivacySandbox;google_apis_playstore;x86_64 | 6 | Google Play Intel x86 Atom_64 System Image
Available Updates:
ID | Installed | Available
------- | ------- | -------
# Check that aidl can be executed
# Search for Aidl
# Run '/home/ubuntu/.buildozer/android/platform/android-sdk/build-tools/33.0.0/aidl'
# Cwd None
# Downloading platform api target if necessary
# Android packages installation done.
# Read available permissions from api-versions.xml
# Run '/usr/bin/python3 -m pythonforandroid.toolchain aab -h --color=always --storage-dir="/home/ubuntu/libapp/.buildozer/android/platform/build-arm64-v8a_x86" --ndk-api=21 --ignore-setup-py --debug'
# Cwd /home/ubuntu/libapp/.buildozer/android/platform/python-for-android
# Check application requirements
# Compile platform
# Run '/usr/bin/python3 -m pythonforandroid.toolchain create --dist_name=myapp --bootstrap=service_library --requirements=python3,kivy --arch arm64-v8a --arch x86 --copy-libs --color=always --storage-dir="/home/ubuntu/libapp/.buildozer/android/platform/build-arm64-v8a_x86" --ndk-api=21 --ignore-setup-py --debug'
# Cwd /home/ubuntu/libapp/.buildozer/android/platform/python-for-android
[WARNING]: prerequisites.py is experimental and does not support all prerequisites yet.
[WARNING]: Please report any issues to the python-for-android issue tracker.
[WARNING]: prerequisites.py is experimental and does not support all prerequisites yet.
[WARNING]: Please report any issues to the python-for-android issue tracker.
[INFO]: Will compile for the following archs: arm64-v8a, x86
[INFO]: Found Android API target in $ANDROIDAPI: 27
[INFO]: Available Android APIs are (27)
[INFO]: Requested API target 27 is available, continuing.
[INFO]: Found NDK dir in $ANDROIDNDK: /home/ubuntu/.buildozer/android/platform/android-ndk-r23b
[INFO]: Found NDK version 23b
[INFO]: Getting NDK API version (i.e. minimum supported API) from user argument
[INFO]: No existing dists meet the given requirements!
[INFO]: No dist exists that meets your requirements, so one will be built.
[ERROR]: Build failed: Conflict detected: 'kivy' inducing dependencies ('sdl2',), and 'genericndkbuild' inducing conflicting dependencies ('genericndkbuild',)
# Command failed: /usr/bin/python3 -m pythonforandroid.toolchain create --dist_name=myapp --bootstrap=service_library --requirements=python3,kivy --arch arm64-v8a --arch x86 --copy-libs --color=always --storage-dir="/home/ubuntu/libapp/.buildozer/android/platform/build-arm64-v8a_x86" --ndk-api=21 --ignore-setup-py --debug
# ENVIRONMENT:
# SHELL = '/bin/bash'
# PWD = '/home/ubuntu/libapp'
# LOGNAME = 'ubuntu'
# XDG_SESSION_TYPE = 'tty'
# MOTD_SHOWN = 'pam'
# HOME = '/home/ubuntu'
# LANG = 'C.UTF-8'
# LS_COLORS = 'rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:'
# PROMPT_COMMAND = 'if [ $? -ne 0 ];then ERROR_FLAG=1;else ERROR_FLAG=;fi; '
# SSH_CONNECTION = 'fd42:9277:650e:9fb1::1 48266 fd42:9277:650e:9fb1:216:3eff:feeb:8f72 22'
# LESSCLOSE = '/usr/bin/lesspipe %s %s'
# XDG_SESSION_CLASS = 'user'
# TERM = 'xterm-256color'
# LESSOPEN = '| /usr/bin/lesspipe %s'
# USER = 'ubuntu'
# SHLVL = '1'
# XDG_SESSION_ID = '1705'
# XDG_RUNTIME_DIR = '/run/user/1000'
# PS1 = '\\[\\033[0m\\]\\u\\[\\033[1;34m\\]@\\[\\033[0;33m\\]$hname\\[\\033[0m\\]:\\[\\033[1;34m\\]\\w\\[\\033[0;32m\\]${ERROR_FLAG:+\\[\\033[1;31m\\]}\\$\\[\\033[0m\\] '
# SSH_CLIENT = 'fd42:9277:650e:9fb1::1 48266 22'
# XDG_DATA_DIRS = '/usr/local/share:/usr/share:/var/lib/snapd/desktop'
# PATH = '/home/ubuntu/.buildozer/android/platform/apache-ant-1.9.4/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/ubuntu/.local/bin'
# DBUS_SESSION_BUS_ADDRESS = 'unix:path=/run/user/1000/bus'
# SSH_TTY = '/dev/pts/1'
# _ = '/home/ubuntu/.local/bin/buildozer'
# OLDPWD = '/home/ubuntu'
# PACKAGES_PATH = '/home/ubuntu/.buildozer/android/packages'
# ANDROIDSDK = '/home/ubuntu/.buildozer/android/platform/android-sdk'
# ANDROIDNDK = '/home/ubuntu/.buildozer/android/platform/android-ndk-r23b'
# ANDROIDAPI = '27'
# ANDROIDMINAPI = '21'
#
# Buildozer failed to execute the last command
# The error might be hidden in the log above this error
# Please read the full log, and search for it before
# raising an issue with buildozer itself.
# In case of a bug report, please add a full log with log_level = 2
ubuntu@fwpoa:~/libapp$
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.