1

I am trying to open Calculator App on my Android 10 device. But when I run my code getting the following error.

org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Please check the server log for more details. Original error: An unknown server-side error occurred while processing the command. 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:17:03' System info: host: 'DESKTOP-3NGN0TH', ip: '192.168.0.152', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_271' Driver info: driver.version: AppiumDriver remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: The JAVA_HOME environment variable must be set for Android Tools to work properly at getResponseForW3CError (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\protocol\errors.js:804:9) at asyncHandler (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\protocol\protocol.js:381:37) Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03' System info: host: 'DESKTOP-3NGN0TH', ip: '192.168.0.152', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_271' Driver info: driver.version: AppiumDriver

Caused by: org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. 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:17:03' System info: host: 'DESKTOP-3NGN0TH', ip: '192.168.0.152', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_271' Driver info: driver.version: AppiumDriver.

Here is my desired Cap:

DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("deviceName", "Noth");
caps.setCapability("udid", "R58M47A4H4R");
caps.setCapability("platformName", "Android");
caps.setCapability("platformVersion", "10");
caps.setCapability("appPackage", "com.sec.android.app.popucalculator");
caps.setCapability("appActivity", "com.sec.android.app.popucalculator.Calculator");
URL url = new URL("http://127.0.0.1:4723/wd/hub");
        
driver = new AppiumDriver<MobileElement>(url, caps);
Caconde
  • 4,177
  • 7
  • 35
  • 32
justdizzle
  • 9
  • 1
  • 4
  • Have you looked at [this](https://stackoverflow.com/questions/25270314/setting-java-home-in-windows/25270459)? – Adrian Russo Dec 29 '20 at 17:08
  • Does this answer your question? [Appium ANDROID\_HOME env variable issues](https://stackoverflow.com/questions/48191990/appium-android-home-env-variable-issues) – dmle Jan 02 '21 at 10:16
  • My JAVA_HOME is pointing to my JDK not JRE. Variable Name: JAVA__HOME Variable Value: C:\Program Files\Java\jdk1.8.0_151. Actually I am not getting what does it mean "The JAVA_HOME environment variable must be set for Android Tools to work properly Build"??? – justdizzle Jan 04 '21 at 16:44

3 Answers3

0

So I changed the JAVA_HOME to "jdk1.8.0_271" cause seems like newer versions doesn't work well and be sure on the variables you added like bin folder or others to have "%JAVA_HOME%" so they refer to what ever u have on JAVA_HOME (Go to Control Panel > System and Security > System > Config advanced system > variables), also validate the Java build path on the properties of the project has the JRE set to 1.8 version (if u change that of course) u will need also to download an old version to use it (that was the way I managed to make it work for me); hope this help u to continue

Luis Frias
  • 11
  • 4
  • Its working now. I completely deleted java (javaw, java.exe files also) from my computer (from appdata, regedit) and just reinstalled back. Here in this link https://stackoverflow.com/questions/6362037/java-error-opening-registry-key – justdizzle Jan 27 '21 at 20:52
0

Restart the system, Once the System Environmental variables ANDROID_HOME, JAVA_HOME, path of the SDK folder is set before creating the running the first program

0

JAVA_HOME should point to a JDK, not a JRE as JRE is used for development purposes. JDK includes the compiler and other tools needed to develop Java applications while JRE does not.

  1. Install the JDK
  2. Set JAVA_HOME

Right-click My Computer and select Properties or press the windows button and search for "Edit the system environment variables.

By default, you will be in the "advance" tab else click on the advance tab select Environment Variables, and then edit JAVA_HOME to point to where the JDK software is located, for example, C:\Program Files\Java\jdk11.0.0

Refer to this doc for more details http://java.sun.com/javase/downloads/index.jsp

Kiran Antony
  • 190
  • 1
  • 15