[AWS Device Farm] - Error when executing on AWS DeviceFarm with Android Device

When i follow katalon’s guide about Interation AWS Devicefarm.
I got some error when executing and fail result
My log:

Feb 22, 2024 5:46:00 AM com.kms.example.aw_ios.utils.ConsoleLogger info
INFO: Execute [sh, -c, /tmp/scratchZHSEwc.scratch/test-packagegFnBri/tmp/.katalon/9.3.0/Katalon_Studio_Engine_Linux_64-9.3.0/katalonc -noSplash  -runMode=console  -projectPath="/tmp/scratchZHSEwc.scratch/test-packagegFnBri/tmp/My_Project"  -retry=0 -testSuitePath="Test Suites/AWS_TestSuite_android" -executionProfile=default -browserType=Remote -reportFolder=/tmp/customer_log_directorya8Kso3 -apiKey=b29e1a55-d0b9-4159-85c0-41740938b172 ] in /tmp/katalon-1773540344794008293

Feb 22, 2024 5:46:03 AM com.kms.example.aw_ios.utils.ConsoleLogger info
INFO: Katalonc:

Feb 22, 2024 5:46:03 AM com.kms.example.aw_ios.utils.ConsoleLogger info
INFO: An error has occurred. See the log file

Feb 22, 2024 5:46:03 AM com.kms.example.aw_ios.utils.ConsoleLogger info
INFO: /tmp/scratchZHSEwc.scratch/test-packagegFnBri/tmp/.katalon/9.3.0/Katalon_Studio_Engine_Linux_64-9.3.0/configuration/1708580762510.log.

Feb 22, 2024 5:46:03 AM com.kms.example.aw_ios.utils.ConsoleLogger info
INFO: Finished executing sh -c /tmp/scratchZHSEwc.scratch/test-packagegFnBri/tmp/.katalon/9.3.0/Katalon_Studio_Engine_Linux_64-9.3.0/katalonc -noSplash  -runMode=console  -projectPath="/tmp/scratchZHSEwc.scratch/test-packagegFnBri/tmp/My_Project"  -retry=0 -testSuitePath="Test Suites/AWS_TestSuite_android" -executionProfile=default -browserType=Remote -reportFolder=/tmp/customer_log_directorya8Kso3 -apiKey=b29e1a55-d0b9-4159-85c0-41740938b172 . Exit code: 13.

E
Time: 59.758
There was 1 failure:
1) test(com.kms.example.aws_ios.test.TestAndroid)
java.lang.AssertionError: Failed to execute Katalon
	at org.junit.Assert.fail(Assert.java:89)
	at com.kms.example.aws_ios.test.TestAndroid.test(TestAndroid.java:93)

FAILURES!!!
Tests run: 1,  Failures: 1
[DEVICEFARM] ########### Entering phase post_test ###########
 
 
[DEVICEFARM] ########### Finish executing testspec ###########
 
[DEVICEFARM] ########### Setting upload permissions ###########
 
 
[DEVICEFARM] Tearing down your device. Your tests report will come shortly.

They didn’t even give me a specific error so I could investigate. I noticed that after executing bash and then finishing, there seemed to be an error with the bash command or something similar.
What do you guys think about this issue?, can I get a specific demo project for the Android case?
pls!

1 Like

Resolve!!!

1 Like

hi, how did you resolve this issue?

Hi,

Please help share with the community how you could resolve this problem. Appreciate your help!

1 Like

just edit YML file, my update yml for android →

version: 0.1

# This flag enables your test to run using Device Farm's Amazon Linux 2 test host. For more information,
# please see https://docs.aws.amazon.com/devicefarm/latest/developerguide/amazon-linux-2.html
android_test_host: amazon_linux_2

# Phases represent collections of commands that are executed during your test run on the test host.
phases:

  # The install phase contains commands for installing dependencies to run your tests.
  # For your convenience, certain dependencies are preinstalled on the test host. To lean about which
  # software is included with the host, and how to install additional software, please see:
  # https://docs.aws.amazon.com/devicefarm/latest/developerguide/amazon-linux-2-supported-software.html

  # Many software libraries you may need are available from the test host using the devicefarm-cli tool.
  # To learn more about what software is available from it and how to use it, please see:
  # https://docs.aws.amazon.com/devicefarm/latest/developerguide/amazon-linux-2-devicefarm-cli.html
  install:
    commands:
      # The Appium server is written using Node.js. In order to run your desired version of Appium,
      # you first need to set up a Node.js environment that is compatible with your version of Appium.
      - devicefarm-cli use node 18
      - node --version

      # Use the devicefarm-cli to select a preinstalled major version of Appium.
      - devicefarm-cli use appium 2
      - appium --version

      # The Device Farm service automatically updates the preinstalled Appium versions over time to
      # incorporate the latest minor and patch versions for each major version. If you wish to
      # select a specific version of Appium, you can use NPM to install it.
      - npm install -g appium@2.2.0

      # For Appium version 2, Device Farm automatically updates the preinstalled UIAutomator2 driver
      # over time to incorporate the latest minor and patch versions for its major version 2. If you
      # want to install a specific version of the driver, you can use the Appium extension CLI to
      # uninstall the existing UIAutomator2 driver and install your desired version:
      - appium driver uninstall uiautomator2
      - appium driver install uiautomator2@2.4.1

      # We recommend setting the Appium server's base path explicitly for accepting commands.
      - export APPIUM_BASE_PATH=/wd/hub

      # Use the devicefarm-cli to setup a Java environment, with which you can run your test suite.
      - devicefarm-cli use java 17
      - java -version

  # The pre-test phase contains commands for setting up your test environment.
  pre_test:
    commands:
      # Setup the CLASSPATH so that Java knows where to find your test classes.
      - export CLASSPATH=$CLASSPATH:$DEVICEFARM_TEST_PACKAGE_PATH/*
      - export CLASSPATH=$CLASSPATH:$DEVICEFARM_TEST_PACKAGE_PATH/dependency-jars/*

      # Appium downloads Chromedriver using a feature that is considered insecure for multitenant
      # environments. This is not a problem for Device Farm because each test host is allocated
      # exclusively for one customer, then terminated entirely. For more information, please see
      # https://github.com/appium/appium/blob/master/packages/appium/docs/en/guides/security.md

      # We recommend starting the Appium server process in the background using the command below.
      # The Appium server log will be written to the $DEVICEFARM_LOG_DIR directory.
      # The environment variables passed as capabilities to the server will be automatically assigned
      # during your test run based on your test's specific device.
      # For more information about which environment variables are set and how they're set, please see
      # https://docs.aws.amazon.com/devicefarm/latest/developerguide/custom-test-environment-variables.html
      - |-
        appium --base-path=$APPIUM_BASE_PATH --log-timestamp \
          --log-no-colors --relaxed-security --default-capabilities \
          "{\"appium:deviceName\": \"$DEVICEFARM_DEVICE_NAME\", \
          \"platformName\": \"$DEVICEFARM_DEVICE_PLATFORM_NAME\", \
          \"appium:app\": \"$DEVICEFARM_APP_PATH\", \
          \"appium:udid\":\"$DEVICEFARM_DEVICE_UDID\", \
          \"appium:platformVersion\": \"$DEVICEFARM_DEVICE_OS_VERSION\", \
          \"appium:chromedriverExecutableDir\": \"$DEVICEFARM_CHROMEDRIVER_EXECUTABLE_DIR\", \
          \"appium:automationName\": \"UiAutomator2\"}" \
          >> $DEVICEFARM_LOG_DIR/appium.log 2>&1 &

      # This code will wait until the Appium server starts.
      - |-
        appium_initialization_time=0;
        until curl --silent --fail "http://0.0.0.0:4723${APPIUM_BASE_PATH}/status"; do
          if [[ $appium_initialization_time -gt 30 ]]; then
            echo "Appium did not start within 30 seconds. Exiting...";
            exit 1;
          fi;
          appium_initialization_time=$((appium_initialization_time + 1));
          echo "Waiting for Appium to start on port 4723...";
          sleep 1;
        done;

  # The test phase contains commands for running your tests.
  test:
    commands:
      # Your test package is downloaded and unpackaged into the $DEVICEFARM_TEST_PACKAGE_PATH directory.
      - cd $DEVICEFARM_TEST_PACKAGE_PATH
      - echo "Starting the Appium Java JUnit test"

      # Below are examples of how to run Appium Java tests on Device Farm using different JUnit versions:
      # 1. JUnit 5 (default configuration)
      # 2. TestNG with support for running JUnit 4 tests
      # 3. JUnit 4
      # Uncomment and adapt the section that corresponds to your chosen JUnit version and test setup.

      # JUnit 5 example:

      # TestNG with JUnit 4 support example:
      # Note: TestNG can directly run JUnit 4 tests. Ensure your TestNG suite XML is set up accordingly.
      # For details, see the TestNG documentation: http://testng.org/doc/documentation-main.html
      # - |-
      #   java -Dappium.screenshots.dir=$DEVICEFARM_SCREENSHOT_PATH org.testng.TestNG -junit \
      #     -testjar *-tests.jar -d $DEVICEFARM_LOG_DIR/test-output -verbose 10

      # JUnit 4 example:
      # Make sure to replace 'Replace.With Your.TestClasses Here' with your actual test classes.
      - export TEST_CLASSES="com.kms.example.aws_ios.test.TestAndroid"
      - java -Dappium.screenshots.dir=$DEVICEFARM_SCREENSHOT_PATH org.junit.runner.JUnitCore $TEST_CLASSES

      # Before starting tests, verify that all dependencies and configurations are in place.
      # For more information, refer to AWS Device Farm's documentation on Appium Java JUnit testing:
      # https://docs.aws.amazon.com/devicefarm/latest/developerguide/test-types-appium.html

  # The post-test phase contains commands that are run after your tests have completed.
  # If you need to run any commands to generating logs and reports on how your test performed,
  # we recommend adding them to this section.
  post_test:
    commands:

# Artifacts are a list of paths on the filesystem where you can store test output and reports.
# All files in these paths will be collected by Device Farm.
# These files will be available through the ListArtifacts API as your "Customer Artifacts".
artifacts:
  # By default, Device Farm will collect your artifacts from the $DEVICEFARM_LOG_DIR directory.
  - $DEVICEFARM_LOG_DIR