0
votes

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);
2
Have you looked at this? - Adrian Russo
Does this answer your question? Appium ANDROID_HOME env variable issues - dmle
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

2 Answers

0
votes

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

0
votes

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