appium-docker-android icon indicating copy to clipboard operation
appium-docker-android copied to clipboard

JAVA_HOME ERROR

Open jsanchezalcala opened this issue 1 year ago • 2 comments

I've just cloned the repo , access to it with the terminal and run the command docker build -t "appium/appium:local" -f Appium/Dockerfile Appium

The error im getting is this one below Testing in mac

[``` +] Building 0.7s (11/17) docker:desktop-linux => [internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 5.22kB 0.0s => [internal] load metadata for docker.io/library/ubuntu:focal-20240530 0.5s => [internal] load .dockerignore 0.0s => => transferring context: 2B 0.0s => [ 1/13] FROM docker.io/library/ubuntu:focal-20240530@sha256:fa17826afb526a9fc7250e0fbcbfd18d03fe7a54849472f86879d8bf562c629e 0.0s => [internal] load build context 0.0s => => transferring context: 307B 0.0s => CACHED [ 2/13] RUN apt-get -qqy update && apt dist-upgrade -y && apt-get -qqy --no-install-recommends install ca-certificates curl gnupg libg 0.0s => CACHED [ 3/13] RUN echo "UTC" > /etc/timezone && dpkg-reconfigure --frontend noninteractive tzdata 0.0s => CACHED [ 4/13] RUN groupadd androidusr --gid 1301 && useradd androidusr --uid 1300 --gid 1301 --create-home --shell /b 0.0s => CACHED [ 5/13] WORKDIR /home/androidusr 0.0s => CACHED [ 6/13] RUN wget -O tools.zip https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip && unzip tools.zip && rm tools.zip && 0.0s => ERROR [ 7/13] RUN mkdir -p ~/.android && touch ~/.android/repositories.cfg && echo y | sdkmanager "platform-tools" && echo y | sdkmanager "build-tools;34 0.1s

[ 7/13] RUN mkdir -p ~/.android && touch ~/.android/repositories.cfg && echo y | sdkmanager "platform-tools" && echo y | sdkmanager "build-tools;34.0.0" && mv ~/.android .android && chown -R 1300:1301 .android: 0.080 0.080 ERROR: JAVA_HOME is set to an invalid directory: /usr/lib/jvm/java-11-openjdk-amd64 0.080 0.080 Please set the JAVA_HOME variable in your environment to match the 0.080 location of your Java installation. 0.080


3 warnings found (use --debug to expand):

  • UndefinedVar: Usage of undefined variable '$JAVA_HOME' (line 54)
  • LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format (line 60)
  • JSONArgsRecommended: JSON arguments recommended for CMD to prevent unintended behavior related to OS signals (line 172) Dockerfile:100

99 | # https://askubuntu.com/questions/885658/android-sdk-repositories-cfg-could-not-be-loaded 100 | >>> RUN mkdir -p ~/.android &&
101 | >>> touch ~/.android/repositories.cfg &&
102 | >>> echo y | sdkmanager "platform-tools" &&
103 | >>> echo y | sdkmanager "build-tools;$ANDROID_BUILD_TOOLS_VERSION" &&
104 | >>> mv ~/.android .android &&
105 | >>> chown -R 1300:1301 .android 106 | ENV PATH=$PATH:$ANDROID_HOME/platform-tools:$ANDROID_HOME/build-tools

ERROR: failed to solve: process "/bin/sh -c mkdir -p ~/.android && touch ~/.android/repositories.cfg && echo y | sdkmanager "platform-tools" && echo y | sdkmanager "build-tools;$ANDROID_BUILD_TOOLS_VERSION" && mv ~/.android .android && chown -R 1300:1301 .android" did not complete successfully: exit code: 1

jsanchezalcala avatar Sep 12 '24 11:09 jsanchezalcala

Line 55 : Change the JAVA_HOME to "/usr/lib/jvm/java-11-openjdk-arm64" with Mac ^^

#===============
# Set JAVA_HOME
#===============
ENV JAVA_HOME="/usr/lib/jvm/java-11-openjdk-arm64" \
PATH=$PATH:$JAVA_HOME/bin

adsl88788190-QwQ avatar Feb 17 '25 11:02 adsl88788190-QwQ

RUN export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java)))) &&
echo "JAVA_HOME=$JAVA_HOME" >> /etc/environment

pkozlovskiy avatar Jul 15 '25 11:07 pkozlovskiy