Closed darcywong00 closed 1 year ago
Per https://android-developers.googleblog.com/2020/12/announcing-android-gradle-plugin.html
Java 11 is a pre-req for using Gradle plugin 7.0 (#4603)
We don't need Java 11 for Keyman 15.0. Deferring to Future
Or the appropriate version of Java at the time.
I've done preliminary work to update the Android projects to build with MS OpenJDK 11.
One dilemma with CI is the builds depend on the environment variable JAVA_HOME
to specify the Java version which is
currently set to Java 8 for stable-16.0
It's possible to use sdkman to control what version of Java gets used for a build.
Note: on Windows GitBash, I had to edit the setup script to remove the checks for unzip
and zip
.
After sdkman is installed, it can install Java as
sdk install java 11.0.18-ms # This installs MS OpenJDK 11
sdk install java 8.0.302-open # This installs Java 8 (Java.net)
Then to set the Java version for a build:
sdk default java 8.0.302-open
or
sdk default java 11.0.18-ms
sdkman is a bash script that needs to be initialized, and uses unbound variables.
I've had to do a non-standard builder script intro:
#!/usr/bin/env bash
#
# Build Keyman Engine for Android, Keyman for Android, OEM FirstVoices Android app,
# Samples: KMsample1 and KMSample2, Test - KeyboardHarness
source "$HOME/.sdkman/bin/sdkman-init.sh"
#set -x
set -eu
...
# OpenJDK 11 defined in .sdkmanrc (#)
set +u
sdk env
set -u
Discussing w/ @mcdurdin , instead of sdkman we can set the environment vars JAVA_HOME_8 JAVA_HOME_11 and have the builder script export JAVA_HOME accordingly...
But a more consolidated look at dependences will probably be needed (whole sprint effort from the team I think)
in #2279 @safolit had started the process of updating the Android build to use Java 11.
Though we're staying with Java 8 for now, I'm documenting the steps for when this happens.
Note, in order to run robolectric for Android SDK 29, we'll need to update Java (see robolectric.properties)
Java SE Development Kit 11 (Java 9 or newer)
Install Java
It is recommended to use openJDK because of oracle license issues. Tested with latest release for openJDK 11 from https://github.com/ojdkbuild/ojdkbuild