Unable to start appium service by AppiumDriverLocalSerivce


#21

In my case it works only if i mention

...........    
.withAppiumJS(
		new File(
	"/usr/local/lib/node_modules/appium/bin/main.js"))
................

#22

Got the same issue after I upgrade the node and Appium to 1.6, any solution of it?


#23

Try to use main.js instead of appium.js like below

service = new AppiumServiceBuilder()
.usingDriverExecutable(new File("/Users/ssimakurthy/local/bin/node"))
.withAppiumJS(new File("/usr/local/lib/node_modules/appium/build/lib/main.js"));


#24

Please clarify if you’re trying to register android node with Selenium HUB with this code ?

are you able to get this issue resolved ?

Thanks in advance.


#25

Just to update on this thread for benefit of others, with below code I could get appiun node registered with Selenium HUB

String nodeConfigFilePath = “/Users/Mobile-Automation/Android-Automation/serenityAppiumFlipkart/EMULATOR_Nexus_4_1.json”;

    	 AppiumDriverLocalService driverLocalService = AppiumDriverLocalService
    			.buildService(new AppiumServiceBuilder()
    					.withAppiumJS(new File("/usr/local/lib/node_modules/appium/build/lib/main.js"))
    					.usingDriverExecutable(new File("/usr/local/bin/node"))
    					//.withIPAddress("127.0.0.1")
    					.usingPort(4445)
    					//.withArgument(GeneralServerFlag.UIID, "123456")    					
    					//.withArgument(AndroidServerFlag.BOOTSTRAP_PORT_NUMBER,
    					//		"" + 2252)
    					//.withArgument(GeneralServerFlag.CHROME_DRIVER_PORT,
    					//		"" + client.getChromeDriverport())
    					//.withArgument(GeneralServerFlag.NO_RESET)
    					.withArgument(GeneralServerFlag.SESSION_OVERRIDE)
    					.withArgument(GeneralServerFlag.LOG_LEVEL, "debug")
    					.withArgument(GeneralServerFlag.CONFIGURATION_FILE, nodeConfigFilePath));
    	//Logger.info("Server url: " + driverLocalService.getUrl());
    	driverLocalService.start();

Before you run this program, make sure to try it out from command line with below command

appium --nodeconfig EMULATOR_Nexus_4_1.json --port 4445

In case you do something wrong as appium --nodeconfig EMULATOR_Nexus_4_1.json --bp 2252, you will get nice output about flags usage

Couple of open queries still as below

  1. it didn’t work with usingAnyFreePort(), I had to explicitly mention port number.

  2. I could register android emulator node, even when it was not in open state, not sure if this is valid ?

Regards,
Vikram


#26

Kindly ignore above answer

Below is the working solution, will share completed project in few weeks

{“capabilities”:[{“browserName”:“Android”,“version”:“4.4.2”,“maxInstances”:1,“platform”:“ANDROID”,“deviceName”:“emulator-5556”}],“configuration”:{“nodeTimeout”:120,“port”:4723,“hubPort”:4444,“proxy”:“org.openqa.grid.selenium.proxy.DefaultRemoteProxy”,“hubHost”:“127.0.0.1”, “nodePolling”:2000, “registerCycle”:10000,“register”:true,“cleanUpCycle”:2000,“timeout”:30000,“maxSession”:1}}

    	nodeConfigFilePath = "/Users/vikram-anna/.../EMULATOR_Nexus_4_2.json";
    	driverLocalService = AppiumDriverLocalService
		.buildService(new AppiumServiceBuilder()
				.withAppiumJS(new File("/usr/local/lib/node_modules/appium/build/lib/main.js"))
				.usingDriverExecutable(new File("/usr/local/bin/node"))					
				.usingPort(4823)
				.withArgument(AndroidServerFlag.BOOTSTRAP_PORT_NUMBER,"4824")
				.withArgument(GeneralServerFlag.SESSION_OVERRIDE)
				.withArgument(GeneralServerFlag.LOG_LEVEL, "debug")
				.withArgument(GeneralServerFlag.CONFIGURATION_FILE, nodeConfigFilePath));

         driverLocalService.start();

Appium - Parallel Execution (Grid)
#27

Yes, using main.js solve the problem, thanks!


#28

Thanks you guys. The problem has been solved. :grinning:


#29

Hi @suroit
How did you resolved it. Even me too facing same issue. I am using appium-desktop 1.1.1 and I installed Node.js manually. Below is my code and error. Can you please help?
appiumService = AppiumDriverLocalService
.buildService(new AppiumServiceBuilder()
.usingDriverExecutable(new File(“C:/Program Files/nodejs/node”))
.withAppiumJS(new File(“C:/Users/ss.k/AppData/Local/Programs/appium-desktop/resources/app/main.js”))
.withIPAddress(“127.0.0.1”)
.usingPort(4723));
appiumService.start();

io.appium.java_client.service.local.AppiumServerHasNotBeenStartedLocallyException: The local appium server has not been started. The given Node.js executable: C:\Program Files\nodejs\node.exe Arguments: [C:\Users\ss.k\AppData\Local\Programs\appium-desktop\resources\app\main.js, --port, 4723, --address, 127.0.0.1]
Process output: Error: Cannot find module ‘electron’


#30

I suggest you try the latest version of appium instead of appium-desktop.


#31

Hi guys,
I meet one problem when I try using AppiumDriverLocalSerivce .start() to launch app server, code like below.
public class StartAppium {

private IOSDriver<MobileElement> iosDriver;
private AppiumDriverLocalService service;

@BeforeClass
public void setUp() throws Exception {

	service = AppiumDriverLocalService
			.buildService(new AppiumServiceBuilder().usingDriverExecutable(new File("/usr/local/bin/node"))
					.withAppiumJS(new File("/usr/local/lib/node_modules/appium/build/lib/main.js"))
					.withIPAddress("127.0.0.1").usingPort(4723));
	service.start();
}

@Test
public void getAppiumStatus() {

}

@AfterClass
public void tearDown() {
	// iosDriver.quit();
	// service.stop();
}

}

however, I got same errors like below, Appium I was using latest one v1.6.5, but strangely it works fine when I use terminal command “node /usr/local/lib/node_modules/appium/build/lib/main.js”

Exception in thread “main” io.appium.java_client.service.local.AppiumServerHasNotBeenStartedLocallyException: The local appium server has not been started. The given Node.js executable: /usr/local/Cellar/node/8.1.4/bin/node Arguments: [/usr/local/lib/node_modules/appium/build/lib/main.js, --port, 57565, --address, 127.0.0.1, --log-level, info, --bootstrap-port, 57567, --suppress-adb-kill-server, --selendroid-port, 57568]

at io.appium.java_client.service.local.AppiumDriverLocalService.start(AppiumDriverLocalService.java:149)
at appium.Manager.DeviceConfigurationImpl.main(DeviceConfigurationImpl.java:45)

Caused by: java.lang.IllegalAccessError: tried to access method com.google.common.util.concurrent.SimpleTimeLimiter.(Ljava/util/concurrent/ExecutorService;)V from class org.openqa.selenium.net.UrlChecker
at org.openqa.selenium.net.UrlChecker.(UrlChecker.java:67)
at io.appium.java_client.service.local.AppiumDriverLocalService.ping(AppiumDriverLocalService.java:113)
at io.appium.java_client.service.local.AppiumDriverLocalService.start(AppiumDriverLocalService.java:136)
… 1 more


#32

@Sun_Yujiang
I am having the same problem of

Caused by: java.lang.IllegalAccessError: tried to access method com.google.common.util.concurrent.SimpleTimeLimiter.(Ljava/util/concurrent/ExecutorService;)V from class org.openqa.selenium.net.UrlChecker

when using AppiumDriverLocalSerivce .start() to start appium server.

Did you get a solution?


#33

public static void startServer() throws Exception {

	try {

		logIOSDriverAPI.info("Starting Appium on terminal from AppiumDriverLocalService");
		Map<String, String> env = new HashMap<String, String>(System.getenv());
		env.put("PATH", "/usr/local/bin:" + env.get("PATH"));
		AppiumServiceBuilder builder = new AppiumServiceBuilder()
				.withIPAddress(appiumInit.SERVERIP)
				.usingPort(appiumInit.APPIUMPORT)
				.withEnvironment(env)
				.withArgument(GeneralServerFlag.LOG_NO_COLORS)
				.withArgument(GeneralServerFlag.SESSION_OVERRIDE)
				.withArgument(GeneralServerFlag.LOG_LEVEL, "warn:error:info")
				.usingDriverExecutable(new File("/usr/local/bin/node"))
				.withAppiumJS(new File("/Applications/Appium.app/Contents/Resources/app/node_modules/appium/build/lib/main.js"));


		driverLocalService = AppiumDriverLocalService.buildService(builder);
		driverLocalService.start();
	

	} catch (Exception e) {
		throw new Exception("Exception occoured while starting the appium server");

	}
	try {

		Thread.sleep(10000);
	} catch (Exception e) {
		e.printStackTrace();
	}

}

#34

Hi,

I am facing same issue. i used above code, but no use.

Environment :
Apium version : 17.1
Node : 8.7.0
xcode :9.0
java clinet : 5.0.4

Using following code to start appium :

Map<String, String> env = new HashMap<>(System.getenv());
env.put(“PATH”, “/usr/local/bin:” + env.get(“PATH”));

AppiumServiceBuilder builder = new AppiumServiceBuilder()
.withArgument(IOSServerFlag.WEBKIT_DEBUG_PROXY_PORT, webkit)
.withIPAddress(“127.0.0.1”)
.usingPort(port).withEnvironment(env)
.usingDriverExecutable(new File("/usr/local/bin/node"))
.withAppiumJS(new File("/usr/local/lib/node_modules/appium/build/lib/main.js"));

AppiumDriverLocalService service = AppiumDriverLocalService.buildService(builder);
service.start();**

Can anyone suggest me how to solve this issue.


#35

public static void startServer() throws Exception {

	try {

		logIOSDriverAPI.info("Starting Appium on terminal from AppiumDriverLocalService");
		Map<String, String> env = new HashMap<String, String>(System.getenv());
		env.put("PATH", "/usr/local/bin:" + env.get("PATH"));
		AppiumServiceBuilder builder = new AppiumServiceBuilder()
				.withIPAddress(appiumInit.SERVERIP)
				.usingPort(appiumInit.APPIUMPORT)
				.withEnvironment(env)
				.withArgument(GeneralServerFlag.LOG_NO_COLORS)
				.withArgument(GeneralServerFlag.SESSION_OVERRIDE)
				.withArgument(GeneralServerFlag.LOG_LEVEL, "warn:error:info")
				.usingDriverExecutable(new File("/usr/local/bin/node"))
				.withAppiumJS(new File("/Applications/Appium.app/Contents/Resources/app/node_modules/appium/build/lib/main.js"));


		driverLocalService = AppiumDriverLocalService.buildService(builder);
		driverLocalService.start();
	

	} catch (Exception e) {
		throw new Exception("Exception occoured while starting the appium server");

	}
	try {

		Thread.sleep(10000);
	} catch (Exception e) {
		e.printStackTrace();
	}

}

#36

i am using the same code and its working