UNC path to .apk file triggered error

In C#, I’ve set Desired Capabilities “app” pointing to an unc .apk file path.

DesiredCapabilities.SetCapability(“app”, @“\\server\shared\dropbox\example.apk”);

Error found in Windows Appium Server log:

info: [debug] Error: Command failed: C:\Windows\system32\cmd.exe /s /c “C:\Android\sdk\platform-tools\adb.exe -s emulator-5554 push “\\\\server\\shared\\dropbox\\example.apk” /data/local/tmp/9dd564b37db477bd9777f304f2e8c3cf.apk”
cannot stat ‘\\\\server\\shared\\dropbox\\example.apk’: No such file or directory

at ChildProcess.exithandler (child_process.js:213:12)
at emitTwo (events.js:87:13)
at ChildProcess.emit (events.js:172:7)
at maybeClose (internal/child_process.js:818:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)

info: [debug] Responding to client with error: {“status”:33,“value”:{“message”:"A new session could not be created. > (Original error: Command failed: C:\\Windows\\system32\\cmd.exe /s /c "C:\\Android\\sdk\\platform-tools\\adb.exe -s

emulator-5554 push "\\\\\\\\server\\\\shared\\\\dropbox\\\\example.apk" /data/local/tmp/9dd564b37db477bd9777f304f2e8c3cf.apk"\ncannot stat ‘\\\\\\\\server\\\\shared\\\\dropbox\\\\example.apk’: No such file or directory\r

\n)",“killed”:false,“code”:1,“signal”:null,“cmd”:"C:\\Windows\\system32\\cmd.exe /s /c "C:\\Android\\sdk\\platform-tools\\adb.exe -s emulator-5554 push "\\\\\\\\server\\\\shared\\\\dropbox\\\\example.apk"

/data/local/tmp/9dd564b37db477bd9777f304f2e8c3cf.apk"",“origValue”:"Command failed: C:\\Windows\\system32\\cmd.exe /s /c "C:\\Android\\sdk\\platform-tools\\adb.exe -s emulator-5554 push "\\\\\\\\server\\\\shared\\\\dropbox\\\\example.apk

In Windows Command Prompt, I tried below command and returned the same error.

C:>adb.exe -s emulator-5554 push “\\\\server\\shared\\dropbox\\example.apk” /d
ata/local/tmp/9dd564b37db477bd9777f304f2e8c3cf.apk

cannot stat ‘\\\\server\\shared\\dropbox\\example.apk’: No such file or directo
ry

Then I tried the same command replacing ‘\\’ with single backslash '' and it works

C:>adb.exe -s emulator-5554 push “\\server\shared\dropbox\example.apk” /data/local/t
mp/9dd564b37db477bd9777f304f2e8c3cf.apk

2480 KB/s (2730639 bytes in 1.075s)

The double backslash caused the issue. So in my code, I tried setting my unc path with forward-slash and still triggered the exact same error message as above

@"//server/shared/dropbox/example.apk

This seems to be a bug, or is there a way to tell the server NOT to translate single backslash to double?

It’s probably more C# related than anything. You might want to look at how to escape slashes in C#. Good reading material here:

https://msdn.microsoft.com/en-us/library/aa691090(v=vs.71).aspx

Hi wreed,

Quoting the example from the link you sent:

string g = “\\server\share\file.txt”; // \server\share\file.txt
string h = @“\\server\share\file.txt”; // \\server\share\file.txt

My snippet code provided above comply with the “string h” example above

Also, this issue only happens on UNC path. Local path and URL work just fine.

Local path
DesiredCapabilities.SetCapability(“app”, @“C:\shared\dropbox\example.apk”);

URL
DesiredCapabilities.SetCapability(“app”, @“http:\\www.server.com\shared\dropbox\example.apk”);

Any idea?

It almost looks like the problem might be with the @ symbol. Can you give it a try by just escaping the slashes, like this:

DesiredCapabilities.SetCapability("app", "\\\\server\\shared\\dropbox\\example.apk");

It does look like you are using the @ symbol correctly, but I’m wondering this might work. LMK if you already tried it.

I am experiencing exactly the same issue as @xiaohundan.

This is NOT a C# issue. I can confirm this since I tried also simply browsing from Appium UI to a network folder and selecing the .APK file residing there and then starting Appium Inspector. The same backslash issue happens and the session fails. This process using local/URL works fine.

NOTE: This works fine from Appium OSX version. Selecting .IPA file from network shared folder (even from a machine running on Windows) and starting Appium Inspector loads the .IPA and to the iOS device with no issues.

So this is an Appium bug. I am using Appium 1.4.0.0. Is this fixed in a newer version or will be fixed in the future?

Thanks.

Facing exactly same issue. This is appium’s bug and not the C# issue.
Has anyone found out a way to get out of this issue?
Or we need to use local path for APKs?