我正在使用Appium,ADB无法在三星设备上安装APK

发布于 2025-01-23 17:28:11 字数 2560 浏览 0 评论 0原文

这是我的代码:

@Test
public void testAppium() throws MalformedURLException{

//Capabilities

DesiredCapabilities capability = new DesiredCapabilities();

capability.setCapability("platformName", "Android");

// Nexus Device
//capability.setCapability("deviceName", "Nexus 5");
//capability.setCapability("platformVersion", "6.0.1");
//capability.setCapability("udid","RF8N21BNXHY");

// Galaxy S20
capability.setCapability("deviceName", "Galaxy S20");
capability.setCapability("platformVersion", "12");
capability.setCapability("udid","RF8N21BNXHY");
capability.setCapability("appWaitPackage", "abc");
capability.setCapability("appWaitActivity","abc");
File file = new File("C:\\Users\\ShahreenMushtaq\\new\\Test\\app-zameen-live-release 
(1).apk");
capability.setCapability("app", file.getAbsolutePath());

相同的代码正在用于具有OS 6.0.1版本的Nexus设备,但不适用于三星设备。

错误:

错误:无法启动Appium会话,错误是:错误:命令失败:c:\ windows \ system32 \ cmd.exe /s /c“” c:\ program Files \ android \ android \ android \ sdk \ sdk \ platform-tools \ \ \ adb.exe“ -s rf8nnnnxhy shell” pm install -r/data/local/tmp/907bcea56cddef5e078d901e601e60af5d98.apk“

info:[debug]错误:命令失败:c:\ windows \ system32 \ cmd.exe /s /c”“ c:\ program files \ android \ android \ sdk \ sdk \ platform -tools \ adb.exe” -s rf8nnnnnnnnnxhy shell“ pm install -r/data/local/tmp/907bcea56cddef5e078d901e60af5d98.apk”

 在childprocess.exithandler(child_process.js:751:12)
在ChildProcess.emit(event.js:110:17)
在Maybeclose(child_process.js:1016:16)
at Process.ChildProcess._handle.Onexit(child_process.js:1088:5)
 

info:[debug]以错误:{“状态”:33,“ value”:{“ message”:“无法创建一个新的会话。(原始错误:命令失败:C:\ Windows) \system32\cmd.exe /s /c ""C:\Program Files\Android\Sdk\platform-tools\adb.exe" -s RF8N21BNXHY shell "pm install -r /data/local/tmp/907bcea56cddef5e078d901e60af5d98.apk" “ \ n)”,“杀死”:false,“代码”:1,“信号”:null,“ cmd”:“ C:\ Windows \ System32 \ cmd.exe /s /c” \ android \ sdk \ platform -tools \ adb.exe“ -s rf8nn21bnxhy shell” pm install -r/data/local/tmp/907bcea56cddef5e078d98d901e601e601e60af5d98.apk 598.apk ".apqumand::firstered firstered firstered firstered firstered::et et y:et y:comm“commourigvalue et:”couligoutile coumcoum couligoutecoum couligouriue \ cmd.exe /s /c“” c:\程序文件\ android \ sdk \ platform -tools \ adb.exe“ -s rf8nn21bnxhy shell” pm install -r /data/local/tmp/907BCEA56BCEA56CDDEF5E5E078D901E60AFKER n“},“ sessionid”:null} 信息:< - POST/WD/HUB/SESSION 500 29539.987 MS-784

请帮助我进行调试,谢谢。

Here is my code:

@Test
public void testAppium() throws MalformedURLException{

//Capabilities

DesiredCapabilities capability = new DesiredCapabilities();

capability.setCapability("platformName", "Android");

// Nexus Device
//capability.setCapability("deviceName", "Nexus 5");
//capability.setCapability("platformVersion", "6.0.1");
//capability.setCapability("udid","RF8N21BNXHY");

// Galaxy S20
capability.setCapability("deviceName", "Galaxy S20");
capability.setCapability("platformVersion", "12");
capability.setCapability("udid","RF8N21BNXHY");
capability.setCapability("appWaitPackage", "abc");
capability.setCapability("appWaitActivity","abc");
File file = new File("C:\\Users\\ShahreenMushtaq\\new\\Test\\app-zameen-live-release 
(1).apk");
capability.setCapability("app", file.getAbsolutePath());

Same code is working for Nexus device having OS version 6.0.1, but not working for samsung devices.

Error:

error: Failed to start an Appium session, err was: Error: Command failed: C:\Windows\system32\cmd.exe /s /c ""C:\Program Files\Android\Sdk\platform-tools\adb.exe" -s RF8N21BNXHY shell "pm install -r /data/local/tmp/907bcea56cddef5e078d901e60af5d98.apk""

info: [debug] Error: Command failed: C:\Windows\system32\cmd.exe /s /c ""C:\Program Files\Android\Sdk\platform-tools\adb.exe" -s RF8N21BNXHY shell "pm install -r /data/local/tmp/907bcea56cddef5e078d901e60af5d98.apk""

at ChildProcess.exithandler (child_process.js:751:12)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1016:16)
at Process.ChildProcess._handle.onexit (child_process.js:1088: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:\Program Files\Android\Sdk\platform-tools\adb.exe" -s RF8N21BNXHY shell "pm install -r /data/local/tmp/907bcea56cddef5e078d901e60af5d98.apk""\n)","killed":false,"code":1,"signal":null,"cmd":"C:\Windows\system32\cmd.exe /s /c ""C:\Program Files\Android\Sdk\platform-tools\adb.exe" -s RF8N21BNXHY shell "pm install -r /data/local/tmp/907bcea56cddef5e078d901e60af5d98.apk""","origValue":"Command failed: C:\Windows\system32\cmd.exe /s /c ""C:\Program Files\Android\Sdk\platform-tools\adb.exe" -s RF8N21BNXHY shell "pm install -r /data/local/tmp/907bcea56cddef5e078d901e60af5d98.apk""\n"},"sessionId":null}
info: <-- POST /wd/hub/session 500 29539.987 ms - 784

Kindly help me in debugging, Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

罪歌 2025-01-30 17:28:11

实际上,您的file_path可能会出现问题。

您可以尝试以下帽子吗?
但是首先从设备卸载您的Appium设置。随之而来的是这些更改。

在Windows(\ filename.apk)上提供文件路径中的路径示例:

String apkpath="<PATH_FOR_APK>";

DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
        desiredCapabilities.setCapability("udid", udid);
        desiredCapabilities.setCapability("platformVersion", platformVersion);
        desiredCapabilities.setCapability("platformName", "Android");
        desiredCapabilities.setCapability("appActivity", "<YOUR_SPLASHACTIVITY>");
        desiredCapabilities.setCapability("automationName","UiAutomator2");
        desiredCapabilities.setCapability("noReset",false);
        desiredCapabilities.setCapability("newCommandTimeout",120);
desiredCapabilities.setCapability("appPackage", "<YOUR_APP_PACKAGENAME>");
File app=new File(apkpath);
    capabilities.setCapability("app", app.getAbsolutePath());

Actually there can be issue on to your file_path.

Can you try with below caps.
But first uninstall your appium setting from device. And along with this do these changes.

Provide path in file path on windows(\filename.apk) example:

String apkpath="<PATH_FOR_APK>";

DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
        desiredCapabilities.setCapability("udid", udid);
        desiredCapabilities.setCapability("platformVersion", platformVersion);
        desiredCapabilities.setCapability("platformName", "Android");
        desiredCapabilities.setCapability("appActivity", "<YOUR_SPLASHACTIVITY>");
        desiredCapabilities.setCapability("automationName","UiAutomator2");
        desiredCapabilities.setCapability("noReset",false);
        desiredCapabilities.setCapability("newCommandTimeout",120);
desiredCapabilities.setCapability("appPackage", "<YOUR_APP_PACKAGENAME>");
File app=new File(apkpath);
    capabilities.setCapability("app", app.getAbsolutePath());
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文