question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Could not start Appium programmatically using apple M1 proc.

See original GitHub issue

The problem

Could not start Appium programmatically using apple M1 proc.

lmihai@192-168-0-113 ~ % echo $SHELL
/bin/zsh lmihai@192-168-0-113 ~ % echo $ANDROID_HOME /Users/lmihai/Library/Android/sdk lmihai@192-168-0-113 ~ % env | grep ANDROID_HOME ANDROID_HOME=/Users/lmihai/Library/Android/sdk lmihai@192-168-0-113 ~ %

Environment

  • Appium version (or git revision) that exhibits the issue: Appium v1.22.0-beta.0
  • Desktop OS/version used to run Appium: macOS Big Sur 11.3.1
  • Node.js version (unless using Appium.app|exe): v15.13.0
  • Npm or Yarn package manager: 7.8.0
  • Mobile platform/version under test: Android (Pixel 2, Android 11)
  • Real device or emulator/simulator: Pixel 2, Android 11

Details

Neither ANDROID_HOME nor ANDROID_SDK_ROOT environment variable was exported when trying to run tests programmatically

Link to Appium logs

https://gist.github.com/vjmaiky/540f14f4bcfa39ee9764eb375f143505

appium-doctor seems to be ok:

info AppiumDoctor Appium Doctor v.1.16.0
info AppiumDoctor ### Diagnostic for necessary dependencies starting ###
info AppiumDoctor  ✔ The Node.js binary was found at: /opt/homebrew/bin/node
info AppiumDoctor  ✔ Node version is 15.13.0
info AppiumDoctor  ✔ Xcode is installed at: /Applications/Xcode.app/Contents/Developer
info AppiumDoctor  ✔ Xcode Command Line Tools are installed in: /Applications/Xcode.app/Contents/Developer
info AppiumDoctor  ✔ DevToolsSecurity is enabled.
info AppiumDoctor  ✔ The Authorization DB is set up properly.
info AppiumDoctor  ✔ Carthage was found at: /opt/homebrew/bin/carthage. Installed version is: 0.38.0
info AppiumDoctor  ✔ HOME is set to: /Users/lmihai
info AppiumDoctor  ✔ ANDROID_HOME is set to: /Users/lmihai/Library/Android/sdk
info AppiumDoctor  ✔ JAVA_HOME is set to: /Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home
info AppiumDoctor    Checking adb, android, emulator
info AppiumDoctor      'adb' is in /Users/lmihai/Library/Android/sdk/platform-tools/adb
info AppiumDoctor      'android' is in /Users/lmihai/Library/Android/sdk/tools/android
info AppiumDoctor      'emulator' is in /Users/lmihai/Library/Android/sdk/emulator/emulator
info AppiumDoctor  ✔ adb, android, emulator exist: /Users/lmihai/Library/Android/sdk
info AppiumDoctor  ✔ 'bin' subfolder exists under '/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home'

Using grep i can see that i have a process in place:

lmihai@192-168-0-113 ~ % ps -A | grep appium
 3327 ??         0:00.96 /opt/homebrew/Cellar/node/15.13.0/bin/node /opt/homebrew/lib/node_modules/appium/build/lib/main.js --port 5138 --address 127.0.0.1 --log-level debug --robot-address HT8281A03687 --chromedriver-port 9537 --bootstrap-port 4777 --relaxed-security --default-capabilities {"app":"/Users/lmihai/Downloads/app.apk","appActivity":"","appPackage":"","automationName":"uiautomator2","deviceName":"HT8281A03687","newCommandTimeout":600,"noReset":false,"platformName":"android","systemPort":8204,"udid":"HT8281A03687","unicodeKeyboard":true}
 3337 ttys000    0:00.00 grep appium

Code To Reproduce Issue [ Good To Have ]

service creation

    private static AppiumDriverLocalService createService(Scenario scenario) throws Exception {

        service = AppiumDriverLocalService
                .buildService(new AppiumServiceBuilder()
                        .usingDriverExecutable(new File(getAndroidJasonResults().getNodeJS()))
                        .withAppiumJS(new File(getAndroidJasonResults().getAppiumJS()))
                        .withIPAddress(getAndroidJasonResults().getIp())
//                        .usingAnyFreePort()
                        .usingPort(getAndroidJasonResults().getAppiumServerPort())
                        .withArgument(GeneralServerFlag.ROBOT_ADDRESS, getAndroidJasonResults().getDeviceID())
                        .withArgument(AndroidServerFlag.BOOTSTRAP_PORT_NUMBER,
                                getAndroidJasonResults().getBootstratPort())
                        .withArgument(AndroidServerFlag.CHROME_DRIVER_PORT, getAndroidJasonResults().getChromePort())
                        .withArgument(Arg.LOG_LEVEL, getAndroidJasonResults().getLogLevel())
                        .withArgument(GeneralServerFlag.RELAXED_SECURITY)
                        .withStartUpTimeOut(120, TimeUnit.SECONDS)
                        .withCapabilities(getCaps(scenario)));
        MyLogger.log.info("+++++++++++++++++++++++ STARTING APPIUM SERVER ++++++++++++++++++++++");
        MyLogger.log.info(String.format(
                "Appium server running for device with UDID: " + getAndroidJasonResults().getDeviceID() + " using bootstrap port: " + getAndroidJasonResults().getBootstratPort() + " and chromedriverport: " +
                        getAndroidJasonResults().getChromePort()));
        MyLogger.log.info("++++++++++++++++++ STARTED APPIUM SERVER ++++++++++++++++++: " + service.getUrl());
        return service;
    }

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10

github_iconTop GitHub Comments

1reaction
vjmaikycommented, May 24, 2021

thank you; now works

 Map<String, String> env = new HashMap<String, String>(System.getenv());
        env.put("ANDROID_HOME", "/Users/lmihai/Library/Android/sdk");
        env.put("JAVA_HOME", "/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home");

.withEnvironment(env)

0reactions
mykola-mokhnachcommented, May 24, 2021

This should not be in PATH, but rather a separate variable

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mac M1 - Unable to programmatically launch Appium using ...
Try to check your setup with github.com/appium/appium-doctor . If everything is fine, please share your code that throws an error. – Max ...
Read more >
Appium IOS tests running when server started manually but ...
However, when I attempt to start the appium server programmatically, the application under test fails to launch, with the following error:
Read more >
Apple Developer Forums
Post your questions, exchange knowledge, and connect with fellow developers and Apple engineers on a variety of software development topics. For questions about ......
Read more >
How to Install Oracle Instant Client on Apple Silicon M1
Step 1: install rosetta2. Use below command to install rosetta2: /usr/sbin/softwareupdate — install-rosetta. Note: The above command will launch the ...
Read more >
neither android_home nor android_sdk_root environment ...
The problem. Could not start Appium programmatically using apple M1 proc. lmihai@192-168-0-113 ~ % echo $SHELL /bin ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found