:
# Recipe for building a python3 app (written using Kivy) for Android-28/Crystax.
#
# ASSUMES Ubantu 18.04 CLEAN INSTALL
# Tested with Windows Subystem for Unix Ubantu 18.04 and Android Pie
#
sudo apt-get update
sudo apt-get upgrade
### Workaround Issue #1327. Java heap issue - thanks JonasT
### Also add this line to .bashrc
export GRADLE_OPTS="-Xms1724m -Xmx5048m -Dorg.gradle.jvmargs='-Xms1724m -Xmx5048m'"
### Install modified P4A Python 2.7 dependencies
# changes to documentation:
# python3-all-dev replaces python2.7-dev
# openjdk-8-jdk replaces openjdk-7-jdk
# apparently not required : libncurses5:i386 libstdc++6:i386 zlib1g:i386
sudo apt-get install -y build-essential ccache git zlib1g-dev python3-all-dev openjdk-8-jdk unzip autoconf libtool
### Install more P4A dependencies
### P4A requires Python 3.6, the default Python version on Ubantu 18 is 3.6
### gradle, virtualenv, pip, pkg, libgl1
### Gradle MUST be installed AFTER openjdk-8-jdk has been installed
sudo apt-get install -y gradle virtualenv python3-pip pkg-config libgl1-mesa-dev
### Install Python packages
### Versions I get: Cython 0.29.1 , Kivy 1.10.1, P4A '0.6.0'
### The P4A version is mostly meaningless it is really a newer 'master'? build
### P4A must be installed with sudo else p4a stub is not created
### P4A requires Cython to be installed with sudo, else it will not find cython
### In some environment with more than one Python version, these two sudo
### might be an issue?
sudo -H pip3 install cython
pip3 install kivy
sudo -H pip3 install git+https://github.com/kivy/python-for-android.git
# Download Crystax and Android Tools (ndk and sdk) to <WHERE_EVER>
# https://www.crystax.net/en/download crystax-ndk-10.3.2-linux-x86_64.tar.xz
# https://developer.android.com/studio/ sdk-tools-linux-4333796.zip
mkdir <WHERE_EVER>
cd <WHERE_EVER>
unzip -d sdk sdk-tools-linux-4333796.zip
tar xf crystax-ndk-10.3.2-linux-x86_64.tar.xz
# Build the Android Tools
cd <WHERE_EVER>/sdk/tools/bin
./sdkmanager "platforms;android-28"
./sdkmanager "build-tools;28.0.3"
### Install Done
### Build app-version-debug.apk
cd <location of app main.py>
# Create a ".p4a" containing (replace text between and including <>)
# An app may need more options than these:
--dist_name=<XXX>
--private .
--package=com.<YYY>.<XYZ>
--name <ZZZ>
--bootstrap=sdl2
--requirements=python3crystax,kivy
--arch=armeabi-v7a
--icon <ICON>.png
--sdk_dir <WHERE_EVER>/sdk
--ndk_dir <WHERE_EVER>/crystax-ndk-10.3.2
--android_api 28
--ndk_version 10.3.2
--ndk-api 21
--version <0.0.0>
# Build .apk with Python for Android
# the first time this will take a while, and it is verbose
# Some stuff fails and recovers, so relax
p4a apk
# Bump the --version for each modified and installed build
# Sometimes an install fails, uninstall the previous version
# Be amazed by p4a, the developers are doing something wonderful.