AppiumTestDistribution / appium-device-farm

This is an Appium 2.0 plugin designed to manage and create driver sessions on available devices.
https://devicefarm.org
Other
339 stars 102 forks source link

Can't upgrade to 9.2.4 or higher #1440

Open ValzRon opened 6 days ago

ValzRon commented 6 days ago

Im running a Docker container with Ubuntu 24.04 and the newest Appium and Espresso driver. When i try to upgrade device farm higher than 9.2.3, my container throws this error

ARG APPIUM_VERSION=2.12.1                    
ARG ESPRESSO_VERSION=3.5.0                   
ARG DEVICE_FARM_VERSION=9.2.4
RUN npm install -g appium@${APPIUM_VERSION} &&     appium driver install espresso@${ESPRESSO_VERSION} &&     appium plugin install --source=npm appium-device-farm@${DEVICE_FARM_VERSION} &&     exit 0
....
✔ Checking if 'appium-device-farm' is compatible
- Installing 'appium-device-farm@9.2.4'
✖ Installing 'appium-device-farm@9.2.4'
Error: ✖ Encountered an error when installing package: npm command 'install --save-dev --no-progress --no-audit --omit=peer --save-exact --global-style --no-package-lock appium-device-farm@9.2.4 --json' failed with code 254.

STDOUT:
{
  "error": {
    "code": "ENOENT",
    "summary": "An unknown git error occurred",
    "detail": "This is related to npm not being able to find a file."
  }
}

Any ideas?

saikrishna321 commented 6 days ago

@ValzRon Can you reinstall appium and try again. Please provide the Dockerfile we can try from our side as well.

ValzRon commented 5 days ago

@saikrishna321 I tried to delete the cache and build the image from scratch, so Appium should be a fresh install.

Here is my Dockerfile:

FROM ubuntu:24.04

ENV DEBIAN_FRONTEND=noninteractive

#============
# Set WORKDIR
#============
WORKDIR /root

#=================================================
# General Packages
#------------------
# openjdk-17-jdk
#   Java
# ca-certificates
#   SSL client
# tzdata
#   Timezone
# zip
#   Make a zip file
# unzip
#   Unzip zip file
# curl
#   Transfer data from or to a server
# wget
#   Network downloader
# libqt5webkit5
#   Web content engine (Fix issue in Android)
# xvfb
#   X virtual framebuffer
# gnupg
#   Encryption software. It is needed for nodejs
#=================================================
RUN apt-get -qqy update && \
    apt-get -qqy --no-install-recommends install \
    openjdk-17-jdk \
    ca-certificates \
    tzdata \
    zip \
    unzip \
    curl \
    wget \
    libqt5webkit5 \
    xvfb \
    gnupg \
    python3 \

  && rm -rf /var/lib/apt/lists/*

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

#====================
# Install Android SDK
#====================
ARG COMMAND_LINE_TOOLS=commandlinetools-linux-8512546_latest

ARG ANDROID_BUILD_TOOLS_VERSION=34.0.0
ARG ANDROID_PLATFORM_VERSION="android-34"

ENV COMMAND_LINE_TOOLS=$COMMAND_LINE_TOOLS \
    ANDROID_BUILD_TOOLS_VERSION=$ANDROID_BUILD_TOOLS_VERSION \
    ANDROID_SDK_ROOT=/root

#============================================================================================================================
# cmdline-tools folder structure tends to change
# Right now the correct path must be $ANDROID_SDK_ROOT/cmdline-tools/version/bin ->
# https://stackoverflow.com/questions/60440509/android-command-line-tools-sdkmanager-always-shows-warning-could-not-create-se
#============================================================================================================================
RUN mkdir -p $ANDROID_SDK_ROOT/cmdline-tools/ && \
    cd $ANDROID_SDK_ROOT/cmdline-tools/ && \
    wget -O cmdline-tools.zip https://dl.google.com/android/repository/${COMMAND_LINE_TOOLS}.zip && \
    unzip cmdline-tools.zip && rm cmdline-tools.zip && \
    mv ~/cmdline-tools/cmdline-tools/ ~/cmdline-tools/latest/ && \
    chmod a+x -R $ANDROID_SDK_ROOT && \
    chown -R root:root $ANDROID_SDK_ROOT

ENV PATH=$PATH:$ANDROID_SDK_ROOT/cmdline-tools/latest:$ANDROID_SDK_ROOT/cmdline-tools/latest/bin

# https://developer.android.com/studio/command-line/sdkmanager
RUN echo y | sdkmanager "platform-tools" && \
    echo y | sdkmanager "build-tools;$ANDROID_BUILD_TOOLS_VERSION" && \
    echo y | sdkmanager "platforms;$ANDROID_PLATFORM_VERSION"

ENV PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools:$ANDROID_SDK_ROOT/build-tools

#============================================================
# Google Cloud SDK
#============================================================
RUN curl -sSL https://sdk.cloud.google.com | bash

# Adding the package path to local
ENV PATH $PATH:/root/google-cloud-sdk/bin

#============================================================
# Install NodeJS and NPM
# https://github.com/nodesource/distributions#ubuntu-versions
#============================================================
ARG NODE_MAJOR_VERSION=23
ARG NPM_VERSION=10.9.0

RUN mkdir -p /etc/apt/keyrings && \
    curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
    echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR_VERSION.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list

RUN apt-get -qqy update && \
    apt-get -qq install nodejs -y

RUN npm install -g npm@${NPM_VERSION}

#=======================================================
# Install latest Appium, Espresso Driver and Device Farm
#=======================================================
ARG APPIUM_VERSION=2.12.1
ARG ESPRESSO_VERSION=3.5.0
ARG DEVICE_FARM_VERSION=9.2.3

RUN npm install -g appium@${APPIUM_VERSION} && \
    appium driver install espresso@${ESPRESSO_VERSION} && \
    appium plugin install --source=npm appium-device-farm@${DEVICE_FARM_VERSION} && \
    exit 0

#=================
# Set Appium Home
#=================
ENV APPIUM_HOME=/root/.appium

#==================================
# Fix Issue with timezone mismatch
#==================================
ENV TZ="US/Pacific"
RUN echo "${TZ}" > /etc/timezone

#======================================
# Scripts to run appium and device farm
#======================================
COPY start_device_farm.sh \
     espressoBuildConfig.json \
     appium-server-config.yaml \
     connect_farm_to_emus.sh \
     /root/

RUN chmod +x /root/start_device_farm.sh && \
    chmod +x /root/connect_farm_to_emus.sh

EXPOSE 4723

#========================================
# SET GRADLE SETTINGS
#========================================
ARG ESPRESSO_SERVER_ROOT=/root/.appium/node_modules/appium-espresso-driver/espresso-server
ARG GRADLE_WRAPPER_PROPERTIES=${ESPRESSO_SERVER_ROOT}/gradle/wrapper/gradle-wrapper.properties

RUN echo 'android.useAndroidX=true\norg.gradle.incremental=true\norg.gradle.daemon=true\norg.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m' > ${ESPRESSO_SERVER_ROOT}/gradle.properties
RUN sed -i 's/gradle-.*\.zip/gradle-8.7-all.zip/g' ${GRADLE_WRAPPER_PROPERTIES}

#===================================================================================
# Change back into workspace to run Emulator connect script and Appium server script
#===================================================================================
RUN cd $WORKDIR
CMD /root/connect_farm_to_emus.sh && /root/start_device_farm.sh