How to use the appium-android-driver.androidHelpers.getJavaVersion function in appium-android-driver

To help you get started, we’ve selected a few appium-android-driver examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github appium / appium-uiautomator2-driver / bin / install.js View on Github external
function doInstall () {
  // UiAutomator2 needs Java. Fail early if it doesn't exist
  let androidHelpers = require('appium-android-driver').androidHelpers;
  androidHelpers.getJavaVersion().then(function () {
    let tries = 0;
    function onErr (err) {
      console.log(err.message);
      let codeNotBuilt = err.message.indexOf('Cannot find module') !== -1;
      if (tries >= MAX_ATTEMPTS) {
        console.log("Tried too many times to install UiAutomator2, failing");
        console.log("Original error: " + err.message);
        throw new Error("Unable to import and run the installer. " +
                        "If you're running from source, run `gulp transpile` " +
                        "and then re-run `npm install`");
      }
      tries++;
      if (codeNotBuilt && !attemptedToBuild) {
        attemptedToBuild = true;
        console.log("Attempting to transpile setup code...");
        exec("npm run transpile", {cwd: path.resolve(__dirname, "..")}, function (err) {