Using Android Images (runtime 28+29) does not work anymore as Android Tools require Java 11 and the images require Corretto 8
Describe the bug Using Android Images (runtime 28+29) does not work anymore as Android Tools require Java 11 and the images require Corretto 8 Error message in codebuild: `[Container] 2022/06/10 16:15:29 Waiting for agent ping
2 | [Container] 2022/06/10 16:15:30 Waiting for DOWNLOAD_SOURCE 3 | [Container] 2022/06/10 16:15:31 Phase is DOWNLOAD_SOURCE 4 | [Container] 2022/06/10 16:15:31 CODEBUILD_SRC_DIR=/codebuild/output/src686247844/src 5 | [Container] 2022/06/10 16:15:31 YAML location is /codebuild/readonly/buildspec.yml 6 | [Container] 2022/06/10 16:15:31 Processing environment variables 7 | [Container] 2022/06/10 16:15:31 Resolved 'android' runtime alias 'latest' to '29'. 8 | [Container] 2022/06/10 16:15:31 Selecting 'android' runtime version '29' based on manual selections... 9 | [Container] 2022/06/10 16:15:31 Selecting 'java' runtime version 'corretto11' based on manual selections... 10 | [Container] 2022/06/10 16:15:31 Runtime 'android' version '29' has a dependency on runtime 'java', but 'java' version 'corretto11' has already been manually selected. Not attempting to override. 11 | [Container] 2022/06/10 16:15:33 Phase complete: DOWNLOAD_SOURCE State: FAILED 12 | [Container] 2022/06/10 16:15:33 Phase context status code: YAML_FILE_ERROR Message: Runtime android version 29 requires selecting one of the following versions of java: corretto8 `
To Reproduce
- set image to Amazon Linux 2 and Android Runtime 29
- start build (I used flutter build apk)
Expected behavior Fluter app should be build
Logs see `[Container] 2022/06/10 16:15:29 Waiting for agent ping
2 | [Container] 2022/06/10 16:15:30 Waiting for DOWNLOAD_SOURCE 3 | [Container] 2022/06/10 16:15:31 Phase is DOWNLOAD_SOURCE 4 | [Container] 2022/06/10 16:15:31 CODEBUILD_SRC_DIR=/codebuild/output/src686247844/src 5 | [Container] 2022/06/10 16:15:31 YAML location is /codebuild/readonly/buildspec.yml 6 | [Container] 2022/06/10 16:15:31 Processing environment variables 7 | [Container] 2022/06/10 16:15:31 Resolved 'android' runtime alias 'latest' to '29'. 8 | [Container] 2022/06/10 16:15:31 Selecting 'android' runtime version '29' based on manual selections... 9 | [Container] 2022/06/10 16:15:31 Selecting 'java' runtime version 'corretto11' based on manual selections... 10 | [Container] 2022/06/10 16:15:31 Runtime 'android' version '29' has a dependency on runtime 'java', but 'java' version 'corretto11' has already been manually selected. Not attempting to override. 11 | [Container] 2022/06/10 16:15:33 Phase complete: DOWNLOAD_SOURCE State: FAILED 12 | [Container] 2022/06/10 16:15:33 Phase context status code: YAML_FILE_ERROR Message: Runtime android version 29 requires selecting one of the following versions of java: corretto8 `
Platform (please complete the following information):
- OS: Linux x86, Amazon Linux 2
Additional context Since July 2021 - https://developer.android.com/studio/releases/gradle-plugin#jdk-11 the Gradle Toolkit provided by Google requires Java 11 The runtime is java corretto8 in the runtime - maybe upping this to java 11 might be the solution? https://github.com/aws/aws-codebuild-docker-images/blob/master/al2/x86_64/standard/3.0/runtimes.yml
Any updates on this? I'm also building an Android project, recently I get an error saying
> Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
But when I changed my java: corretto8 to java: corretto11 in buildspec.yml I got a new error
[Container] 2022/08/05 23:21:40 Phase context status code: YAML_FILE_ERROR Message: Runtime android version 29 requires selecting one of the following versions of java: corretto8
I'm using Ubuntu standard 4:0
This is for Ubuntu...
As a workaround, change to version 5 of the Ubuntu Image and modify the install phase like this:
version: 0.2
phases:
install:
runtime-versions:
# android: 29
java: corretto11
nodejs: 14
commands:
- export ANDROID_TOOLS_FILENAME="commandlinetools-linux-8512546_latest.zip"
- wget https://dl.google.com/android/repository/$ANDROID_TOOLS_FILENAME -P ~ > /dev/null
- unzip ~/$ANDROID_TOOLS_FILENAME -d ~ > /dev/null 2>&1
- mkdir -p /usr/local/android-sdk-linux/cmdline-tools
- mv ~/cmdline-tools /usr/local/android-sdk-linux/cmdline-tools/latest
- export PATH=$PATH:/usr/local/android-sdk-linux/cmdline-tools/latest:/usr/local/android-sdk-linux/cmdline-tools/latest/bin:/usr/local/android-sdk-linux/platform-tools
- export ANDROID_SDK_ROOT=/usr/local/android-sdk-linux
- yes | sdkmanager --licenses > /dev/null
- sdkmanager "platform-tools" "platforms;android-31" > /dev/null
- sdkmanager "build-tools;31.0.0" > /dev/null
This installs the android tools manually in an environment with Java 11 and Node.js 14. Replace the android command line tools version if necessary in ANDROID_TOOLS_FILENAME. Android v31 is installed.
@appleoddity workaround, works for me too. 👍
@appleoddity thanks. your solution helped us