I wanted to know, Can i install the <sample.apk> on emulator using Java code, Please let me know

I’m new to appium and tried the sample from uTest - The Professional Network for Testers, when I run the code using testNG I get this error as In APPIUM

error: Failed to start an Appium session, err was: Error: Bad app: C:\MobileTesting\RunningAppium\apps\Chess Free.apk. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Error locating the app: ENOENT, stat ‘C:\MobileTesting\RunningAppium\apps\Chess Free.apk’

info: [debug] Using local app from desired caps: C:\MobileTesting\RunningAppium\apps\Chess Free.apk
info: [debug] Got configuration error, not starting session
info: [debug] Cleaning up appium session
info: [debug] Error: Bad app: C:\MobileTesting\RunningAppium\apps\Chess Free.apk. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Error locating the app: ENOENT, stat ‘C:\MobileTesting\RunningAppium\apps\Chess Free.apk’
at [object Object]. (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android-common.js:56:13)
at C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\device.js:82:16
at Object.oncomplete (fs.js:107:15)
info: [debug] Responding to client with error: {“status”:33,“value”:{“message”:“A new session could not be created. (Original error: Bad app: C:\MobileTesting\RunningAppium\apps\Chess Free.apk. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Error locating the app: ENOENT, stat ‘C:\MobileTesting\RunningAppium\apps\Chess Free.apk’)”,“origValue”:“Bad app: C:\MobileTesting\RunningAppium\apps\Chess Free.apk. App paths need to be absolute, or relative to the appium server install dir, or a URL to compressed file, or a special app name. cause: Error: Error locating the app: ENOENT, stat ‘C:\MobileTesting\RunningAppium\apps\Chess Free.apk’”},“sessionId”:null}
info: ← POST /wd/hub/session 500 8.990 ms - 724

Code:

File classpathRoot = new File(System.getProperty(“user.dir”));
File appDir = new File(classpathRoot, “/apps”);
File app = new File(appDir, “Chess Free.apk”);

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, “”); //Name of mobile web browser to automate. Should be an empty string if automating an app instead.
capabilities.setCapability(“platformName”, “Android”);
capabilities.setCapability(CapabilityType.VERSION, “4.4.2”);;
capabilities.setCapability(“deviceName”, “Samsung”);
capabilities.setCapability(CapabilityType.PLATFORM, “WINDOWS”);
capabilities.setCapability(“app”, app.getAbsolutePath());
//capabilities.setCapability(“appPackage”, “com.example.android.contactmanager”);
//capabilities.setCapability(“appActivity”, “.ContactManager”);
capabilities.setCapability(“appPackage”, “uk.co.aifactory.chessfree”);
capabilities.setCapability(“appActivity”, “.ChessFreeActivity”);
driver = new AndroidDriver(new URL(“http://127.0.0.1:4723/wd/hub”), capabilities);

Please let me know how to solve this issue, I can run the chrome using same emulator. However I cant make this app ro run…

I guess app path (.apk file path ) would be wrong. Please crosscheck with that.

Error: Bad app:
The above error will come when app name/path given wrongly.

I think you need to escape the space.

hi @preethi

File app = new File(appDir, “Chess Free.apk”)

Remove the space between Chees and Free words and then try

I solved this problem thanks

You should put how you solved it.

1 Like

I solved this by removing the space b/w chess and free and added the .apk file inside the current project folder and provided the path of the folder.

This worked.

Will this not work when we put the application name in double quotes? Strange. :worried: