From 14e782d6c5662bf0649a28c58b7e96337442c609 Mon Sep 17 00:00:00 2001 From: Richard Tibbles Date: Tue, 22 Aug 2023 14:00:08 -0700 Subject: [PATCH 1/2] Fix command line tools setup. Tweak README.md. --- Makefile | 13 ++++++------- README.md | 32 ++++++++++++++++---------------- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index 315ce507..d8cb9529 100644 --- a/Makefile +++ b/Makefile @@ -191,14 +191,13 @@ logcat: $(SDK)/cmdline-tools/latest/bin/sdkmanager: @echo "Downloading Android SDK command line tools" - wget https://dl.google.com/android/repository/commandlinetools-$(PLATFORM)-7583922_latest.zip + wget https://dl.google.com/android/repository/commandlinetools-$(PLATFORM)-9477386_latest.zip rm -rf cmdline-tools - unzip commandlinetools-$(PLATFORM)-7583922_latest.zip -# This is unfortunate since it will download the command line tools -# again, but after this it will be properly installed and updatable. - yes y | ./cmdline-tools/bin/sdkmanager "cmdline-tools;latest" --sdk_root=$(SDK) - rm -rf cmdline-tools - rm commandlinetools-$(PLATFORM)-7583922_latest.zip + unzip commandlinetools-$(PLATFORM)-9477386_latest.zip -d $(SDK) + mv $(SDK)/cmdline-tools $(SDK)/latest + mkdir -p $(SDK)/cmdline-tools + mv $(SDK)/latest $(SDK)/cmdline-tools/latest + rm commandlinetools-$(PLATFORM)-9477386_latest.zip sdk: $(SDK)/cmdline-tools/latest/bin/sdkmanager yes y | $(SDK)/cmdline-tools/latest/bin/sdkmanager "platform-tools" diff --git a/README.md b/README.md index 634365b0..b9841ed0 100644 --- a/README.md +++ b/README.md @@ -2,35 +2,23 @@ Wraps Kolibri in an android-compatibility layer. Relies on Python-For-Android to build the APK and for compatibility on the Android platform. -## Build on Docker - -This project was primarily developed on Docker, so this method is more rigorously tested. - -1. Install [docker](https://www.docker.com/community-edition) - -2. Build or download a Kolibri WHL file, and place in the `whl/` directory. - -3. Run `make run_docker`. - -4. The generated APK will end up in the `bin/` folder. - ## Development Flow 1. Setup a Python virtual environment in which to do development. The Kolibri developer documentation has a [How To guide for doing this with pyenv](https://kolibri-dev.readthedocs.io/en/develop/howtos/pyenv_virtualenv.html) but any Python virtualenv should work. -2. Install the Android SDK and Android NDK. +2. Ensure you have all [necessary packages for Python for Android](https://python-for-android.readthedocs.io/en/latest/quickstart/#installing-dependencies). + +3. The `make setup` command will install the Android SDK and Android NDK. N.B. if you would like these to be installed to a different location then you can set an environment variable, e.g.: By default it is set to `export ANDROID_SDK_ROOT=./android_root` Run `make setup`. -3. Install the Python dependencies: +4. Install the Python dependencies: `pip install -r requirements.txt` -4. Ensure you have all [necessary packages for Python for Android](https://python-for-android.readthedocs.io/en/latest/quickstart/#installing-dependencies). - 5. Build or download a Kolibri WHL file, and place it in the `whl/` directory. To download a Kolibri WHL file, you can use `make get-whl whl=` from the command line. It will download it and put it in the correct directory. @@ -88,6 +76,18 @@ You could also do so using [Weinre](https://people.apache.org/~pmuellr/weinre/do - Uninstall from terminal using `adb shell pm uninstall org.learningequality.Kolibri`. ([Docs](https://developer.android.com/studio/command-line/adb#pm)) - Docker shouldn't be rebuilding very often, so it shouldn't be using that much storage. But if it does, you can run `docker system prune` to clear out all "dangling" images, containers, and layers. If you've been constantly rebuilding, it will likely get you several gigabytes of storage. +## Build on Docker + +This project was previously developed on Docker, but this method has not recently been tested. + +1. Install [docker](https://www.docker.com/community-edition) + +2. Build or download a Kolibri WHL file, and place in the `whl/` directory. + +3. Run `make run_docker`. + +4. The generated APK will end up in the `bin/` folder. + ## Docker Implementation Notes The image was optimized to limit rebuilding and to be run in a developer-centric way. `scripts/rundocker.sh` describes the options needed to get the build running properly. From cb8ac1c4637c246a84ef29281d63a02361b6f3cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Redrejo?= Date: Wed, 23 Aug 2023 17:56:36 +0200 Subject: [PATCH 2/2] Fixes some of the Readme steps --- Dockerfile | 3 +-- README.md | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9adbea53..9e6a8d86 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,8 +38,7 @@ RUN dpkg --add-architecture i386 && \ python3 \ && apt-get clean -# Use java 1.8 because Ubuntu's gradle version doesn't support 1.11 -ENV JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 +ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 ENV PATH=$PATH:$JAVA_HOME RUN curl https://bootstrap.pypa.io/pip/3.6/get-pip.py -o get-pip.py && python3 get-pip.py diff --git a/README.md b/README.md index b9841ed0..c80b3adc 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Wraps Kolibri in an android-compatibility layer. Relies on Python-For-Android to 1. Setup a Python virtual environment in which to do development. The Kolibri developer documentation has a [How To guide for doing this with pyenv](https://kolibri-dev.readthedocs.io/en/develop/howtos/pyenv_virtualenv.html) but any Python virtualenv should work. -2. Ensure you have all [necessary packages for Python for Android](https://python-for-android.readthedocs.io/en/latest/quickstart/#installing-dependencies). +2. Ensure you have all [necessary packages for Python for Android](https://python-for-android.readthedocs.io/en/latest/quickstart/#installing-dependencies). Ensure you install java version 1.11, `sudo apt install openjdk-11-jdk` , and set it as the default java version: `sudo update-alternatives --auto javac` and `sudo update-alternatives --auto java`. 3. The `make setup` command will install the Android SDK and Android NDK. @@ -19,13 +19,13 @@ Run `make setup`. `pip install -r requirements.txt` -5. Build or download a Kolibri WHL file, and place it in the `whl/` directory. +5. Build or download a Kolibri tar file, and place it in the `tar/` directory. -To download a Kolibri WHL file, you can use `make get-whl whl=` from the command line. It will download it and put it in the correct directory. +To download a Kolibri WHL file, you can use `make get-tar tar=` from the command line. It will download it and put it in the correct directory. 6. By default the APK/AAB will be built for most architectures supported by Python for Android. To build for a smaller set of architectures, set the `ARCHES` environment variable. Run `p4a archs` to see the available targets. -7. Run `make p4a_android_project` this will do all of the Python for Android setup up until the point of actually building an APK or AAB. +7. Run `make p4a_android_project` this will do all of the Python for Android setup up. After, you can run `make kolibri.apk` or `make kolibri.apk.unsigned` if you want to build the apk in the console. N.B. You will need to rerun this step any time you update the Kolibri WHL file you are using, or any time you update the Python code in this repository.