Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
233 views
in Technique[技术] by (71.8m points)

java - In Eclipse while doing appium testing ...How to set JAVA_HOME environment variable for Android Tools to work properly?

Original error: The JAVA_HOME environment variable must be set for Android Tools to work properly

My code:

    DesiredCapabilities capabilities = new DesiredCapabilities();
    
    capabilities.setCapability("BROWSER_NAME", "Android");
    capabilities.setCapability("VERSION", "9.0");

    // ZY224HFLPG is device name
    capabilities.setCapability("deviceName","ZY224HFLPG");
    capabilities.setCapability("platformName","Android"); 

    capabilities.setCapability("appPackage", "com.android.calculator2");
    capabilities.setCapability("appActivity","com.android.calculator2.Calculator"); 

driver = new RemoteWebDriver(new URL("http://127.0.0.1:4725/wd/hub"), capabilities);

Output:

org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Cannot verify the signature of 'C:UserskarakrisAppDataLocalProgramsAppium esourcesapp ode_modulesappium ode_modulesappium-uiautomator2-serverapksappium-uiautomator2-server-v4.15.0.apk'.

Original error: The JAVA_HOME environment variable must be set for Android Tools to work properly

Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53' System info: host: 'LIN19003760', ip: '192.168.0.106', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '15.0.1' Driver info: driver.version: RemoteWebDriver remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: Cannot verify the signature of 'C:UserskarakrisAppDataLocalProgramsAppium esourcesapp ode_modulesappium ode_modulesappium-uiautomator2-serverapksappium-uiautomator2-server-v4.15.0.apk'. Original error: The JAVA_HOME environment variable must be set for Android Tools to work properly at getResponseForW3CError (C:UserskarakrisAppDataLocalProgramsAppium esourcesapp ode_modulesappium ode_modulesappium-base-driverlibprotocolerrors.js:804:9) at asyncHandler (C:UserskarakrisAppDataLocalProgramsAppium esourcesapp ode_modulesappium ode_modulesappium-base-driverlibprotocolprotocol.js:384:37) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:64) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) . . .

WHAT SHOULD HAVE TO DO?

question from:https://stackoverflow.com/questions/65940426/in-eclipse-while-doing-appium-testing-how-to-set-java-home-environment-variab

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Below is the process to set environment variables in eclipse:

  1. Right click on java file which is to be executed/run.
  2. Select Run As--> Run Configurations
  3. Select Environment Tab
  4. Click on New Button and provide Env variable name and value
  5. Click on OK
  6. Click on Apply button.
  7. Close the window Done

Eclipse screen shot


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...