Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(android): Update projects to use Java 11 #8543

Merged
merged 14 commits into from
Apr 10, 2023

Conversation

darcywong00
Copy link
Contributor

@darcywong00 darcywong00 commented Mar 29, 2023

Fixes #2293 (Updating to Java 11)
Also fixes #8542 by moving some configure steps to build actions

After deferring multiple releases, this updates the Android projects to use Java 11 instead of Java 8.
For CI compatibility, the build.sh will override JAVA_HOME for to JAVA_HOME_11 and then revert to JAVA_HOME_8 when the build is finished.

One notable Gradle change is the Keyman Engine for Android artifact name changes
from KMEA/app/build/outputs/aar/${CONFIG}/keyman-engine.aar
to KMEA/app/build/outputs/aar/keyman-engine-${CONFIG}.aar"

The build also flagged notificationManager.notify needing to catch SecurityException.

CI Test configs updated to use the top level Android build.sh script (handles updating JAVA_HOME to JDK 11 for the build).
TODO:

  • Update Release config - Updated build-publish.sh to also override JAVA_HOME to JDK 11

User Testing

Setup - Install the PR builds of "Keyman for Android" and "FirstVoices for Android"

  • TEST_KEYMAN - Verifies Keyman app functions
  1. Launch Keyman for Android and dismiss the "Get Started" menu
  2. From the Keyman app, type on the default sil_euro_latin keyboard
  3. Verify the in-app keyboard functions
  4. From Keyman settings --> Search for another keyboard (e.g. khmer_angkor) from keyman.com and install
  5. From the Keyman app, type on the khmer_angkor keyboard
  6. Verify the in-app keyboard functions
  7. From the "Get Started" menu, enable Keyman as a system keyboard and set as default system keyboard
  8. Launch a separate app (e.g. Google Chrome)
  9. Select a textfield
  10. With Keyman as a system keyboard, type
  11. Verify the system keyboard functions
  • TEST_FV - Verifies FirstVoices for Android functions
  1. Launch FirstVoices for Android
  2. From the FirstVoices "Setup" menu, add a region --> keyboard
  3. From the "Setup" menu, enable FirstVoices as a system keyboard and set as the default system keyboard
  4. Launch a sparate app (e.g. Google Chrome)
  5. Select a textfield
  6. With FirstVoices as the system keyboard, type
  7. Verify the system keyboard functions

@keymanapp-test-bot keymanapp-test-bot bot added has-user-test user-test-required User tests have not been completed labels Mar 29, 2023
@keymanapp-test-bot
Copy link

keymanapp-test-bot bot commented Mar 29, 2023

User Test Results

Test specification and instructions

  • TEST_KEYMAN (PASSED): Tested with the attached PR build (17.0.80-alpha-test-8543) in Android 12 / API 31 emulator and here is my observation : 1. Verified that the Keyman In-App functions are working fine. Also, verified that after changing the keyman as the system keyboard, I was able to type in the text field without having any issues. Seems to be working as expected. (notes)
  • TEST_FV (PASSED): Tested with the attached PR build (17.0.80-alpha-test-8543) in Android 12 / API 31 emulator and here is my observation : 1. Set the FirstVoices as system keyboard. 2. Opened Chrome browser. I was able to type in the text field with FirstVoices keyboard without having any problem. Seems to be working as expected. (notes)

Test Artifacts

@bharanidharanj
Copy link

Test Results

  • TEST_KEYMAN (PASSED): Tested with the attached PR build (17.0.80-alpha-test-8543) in Android 12 / API 31 emulator and here is my observation : 1. Verified that the Keyman In-App functions are working fine. Also, verified that after changing the keyman as the system keyboard, I was able to type in the text field without having any issues. Seems to be working as expected.

@bharanidharanj
Copy link

Test Results

  • TEST_FV (PASSED): Tested with the attached PR build (17.0.80-alpha-test-8543) in Android 12 / API 31 emulator and here is my observation : 1. Set the FirstVoices as system keyboard. 2. Opened Chrome browser. I was able to type in the text field with FirstVoices keyboard without having any problem. Seems to be working as expected.

@keymanapp-test-bot keymanapp-test-bot bot removed the user-test-required User tests have not been completed label Mar 29, 2023
android/build.sh Outdated Show resolved Hide resolved
@jahorton
Copy link
Contributor

For CI compatibility, the build.sh will override JAVA_HOME for to JAVA_HOME_11 and then revert to JAVA_HOME_8 when the build is finished.

I assume this is in order to continue maintenance of Keyman for Android 16.0? Any other reasons of note or causes to be aware of before we fully convert over at some point in the future?

sdk=31
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: update the comment (since we can use something newer now - yay!)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Also bumped sdk higher to 33.

android/KMEA/build.gradle Show resolved Hide resolved
android/build.sh Outdated
@@ -37,6 +37,10 @@ builder_describe \

builder_parse "$@"

# Override JAVA_HOME to OpenJDK 11
builder_heading "Setting JAVA_HOME to OpenJDK 11"
export JAVA_HOME=${JAVA_HOME_11}
Copy link
Contributor

@jahorton jahorton Mar 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, a problem here:

  • If the build fails, I doubt that JAVA_HOME will be restored properly given the current implementation of this build script.
    • To be extra-explicit, this is the requested change.

It may be wise to extend the existing builder trap (because only one may be set...) and add functionality there to ensure that JAVA_HOME is fixed before re-throwing an exit-triggering exit code.

For the in-repo reference, refer to _builder_failure_trap via CTRL-F. It'd probably be best to simply write your own trap and have it call this one, and then replace this one with your version.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JAVA_HOME doesn't need to be reset -- you don't modify the environment for the caller of the script with export, only with child processes. (You can only modify 'parent' environment with sourced scripts -- which run in the same process not a child process.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good to hear. I inferred that it did based on the implementation I reviewed, but didn't investigate it with any serious depth. Glad to hear it's not actually going to be an issue.

@darcywong00
Copy link
Contributor Author

I assume this is in order to continue maintenance of Keyman for Android 16.0?

Right - 16.0 is still building with JDK 8.

Copy link
Member

@mcdurdin mcdurdin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good but I think we should tweak the JAVA_HOME_11 usage a bit.

@@ -81,7 +81,7 @@ fi
if builder_start_action configure; then

# Copy Keyman Engine for Android
cp "$KEYMAN_ROOT/android/KMEA/app/build/outputs/aar/${CONFIG}/keyman-engine.aar" "$KEYMAN_ROOT/android/KMAPro/kMAPro/libs/keyman-engine.aar"
cp "$KEYMAN_ROOT/android/KMEA/app/build/outputs/aar/keyman-engine-${CONFIG}.aar" "$KEYMAN_ROOT/android/KMAPro/kMAPro/libs/keyman-engine.aar"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per earlier discussions (#8542), this should be done in build action.

Comment on lines 61 to 64
if [ -f .build-builder ]; then
builder_heading "Setting JAVA_HOME to OpenJDK 11"
export JAVA_HOME=${JAVA_HOME_11}
fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this to a function in build-utils.sh?

android/build-publish.sh Outdated Show resolved Hide resolved
android/build.sh Outdated Show resolved Hide resolved
android/build.sh Outdated Show resolved Hide resolved
docs/build/windows.md Show resolved Hide resolved
docs/build/windows.md Outdated Show resolved Hide resolved
docs/build/windows.md Outdated Show resolved Hide resolved
docs/build/windows.md Outdated Show resolved Hide resolved
@@ -341,6 +346,17 @@ To include UserDefines.mak in the build, use the command line parameter
`-DUSERDEFINES`. You can also set an environment variable `USERDEFINES=1` to get
the same result.

### JAVA_HOME
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this whole section should be in a non-platform-specific doc?

Copy link
Contributor

@jahorton jahorton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per @mcdurdin's remarks about build-script environment variable handling, my concerns re JAVA_HOME are satisfied now.

@github-actions github-actions bot added common/ common/resources/ Build infrastructure labels Mar 31, 2023
@darcywong00 darcywong00 requested a review from mcdurdin April 8, 2023 02:58
Copy link
Member

@mcdurdin mcdurdin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@darcywong00 darcywong00 merged commit d2cacd5 into master Apr 10, 2023
@darcywong00 darcywong00 deleted the chore/android/java-11 branch April 10, 2023 02:20
@keyman-server
Copy link
Collaborator

Changes in this pull request will be available for download in Keyman version 17.0.84-alpha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: builder script consistency re 'configure' actions feat(android) Update to Java 11
6 participants