当前位置: 首页 > 知识库问答 >
问题:

通过Appium启动(whatsapp)移动应用程序会导致“com.whatsaapp.Main从未启动”错误

楚元章
2023-03-14

通过 Appium 服务器执行代码会导致应用程序启动几秒钟。然后程序停止工作,并出现错误:

线程“主”组织 openqa.selenium.SessionNot创建异常:处理命令时发生未知的服务器端错误。原始错误:“com.whatsapp.Main”从未启动(警告:服务器未提供任何堆栈跟踪信息) 命令持续时间或超时:0 毫秒 生成信息: 版本: “3.3.1”,修订版:“5234b32”,时间:“2017-03-10 09:04:52 -0800” 系统信息:主机:“DESKTOP-7P0AKLE”,ip:“172.20.167.164”,os.name:“Windows 10”,os.arch:“amd64”,操作系统:“10.0”,java.version:“9”驱动程序信息:驱动程序:驱动程序:位于 java.base/jdk 的 RemoteWebDriver。内部.reflect.NativeConconssorAccesorImpssor.newInstance0(Native Method) at java.base/jdk.internal.reflectsence(NativeConctussorAccessorImpl.java:62) 在 java.base/jdk.internal.reflect.委派连接结构访问访问imple.newInstance(委派构造过程访问命令.java:45) 在 java.base/java.lang.reflect.constructor.newinstance(构造函数.java:488) 在ErrorHandler.java:216) at org.openqa.selenium.remote.errorHandler.throwIfResponseFailed(ErrorHandler.java:168) at org.openqa.selenium.remote.protocol手握.java:367) 在 org.openqa.selenium.remote.protocol手摇.createSession(协议手握.java:113) 在 org.openqa.selenium.remote.remote.执行(httpCommandExcutor.java:141) 在 org.openqa.selenium.remote.Remote.Remote.RemoteWebDriver.execute(RemoteWebDriver.java:604) 在在 org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:244) at org.openqa.selenium.remote.RemoteWebDriver.(远程网络驱动程序.java:131) 在组织.openqa.硒.远程.远程网络驱动程序.(远程网络驱动程序.java:158) 在应用程序。TestManager.createAppiumWebDriver(TestManager.java:227) at app.TestManager.runTests(TestManager.java:167) at app.TestManager.run(测试管理器.java:43) at app.主启动器(启动器.java:11)

我使用的是 Appium 服务器 v1.7.0

我的能力:

    DesiredCapabilities capabilities = new DesiredCapabilities();

    capabilities.setCapability("deviceName", "Galaxy S6");
    capabilities.setCapability("platformVersion", "7.0");
    capabilities.setCapability("platformName", "Android");

    java.io.File file = new java.io.File("D:\\Prac\\JavaWorkspace\\TestAutomationPartners\\apk\\com.whatsapp.apk");
    capabilities.setCapability("app", file.getAbsolutePath());

    //???
    capabilities.setCapability("app-wait-activity", "Main");
    capabilities.setCapability("app-wait-activity", "MainActivity");
    //???

根据我自己对这个问题的研究:我想我应该等待“主”活动开始。我想我是通过添加应用程序等待活动功能来实现这一点的。但没有结果……(应用程序也会启动几秒钟,所以“Main”活动应该已经在运行了,不是吗?)

以下是来自 Appium 服务器的日志

并在此处完成日志:

> The server is running

> [Appium] Welcome to Appium v1.7.0
[Appium] Non-default server args:
[Appium]   address: 127.0.0.1
[Appium] Appium REST http interface listener started on 127.0.0.1:4723
[HTTP] --> POST /wd/hub/session {"desiredCapabilities":{"app":"D:\\Prac\\JavaWorkspace\\TestAutomationPartners\\apk\\com.whatsapp.apk","app-wait-activity":"MainActivity","platformVersion":"7.0","platformName":"Android","deviceName":"Galaxy S6"},"requiredCapabilities":{},"capabilities":{"desiredCapabilities":{"app":"D:\\Prac\\JavaWorkspace\\TestAutomationPartners\\apk\\com.whatsapp.apk","app-wait-activity":"MainActivity","platformVersion":"7.0","platformName":"Android","deviceName":"Galaxy S6"},"requiredCapabilities":{}},"alwaysMatch":{"app":"D:\\Prac\\JavaWorkspace\\TestAutomationPartners\\apk\\com.whatsapp.apk","app-wait-activity":"MainActivity","platformVersion":"7.0","platformName":"Android","deviceName":"Galaxy S6"},"firstMatch":[]}
[MJSONWP] Calling AppiumDriver.createSession() with args: [{"app":"D:\\Prac\\JavaWorkspace\\TestAutomationPartners\\apk\\com.whatsapp.apk","app-wait-activity":"MainActivity","platformVersion":"7.0","platformName":"Android","deviceName":"Galaxy S6"},{},{"desiredCapabilities":{"app":"D:\\Prac\\JavaWorkspace\\TestAutomationPartners\\apk\\com.whatsapp.apk","app-wait-activity":"MainActivity","platformVersion":"7.0","platformName":"Android","deviceName":"Galaxy S6"},"requiredCapabilities":{}}]
[BaseDriver] Event 'newSessionRequested' logged at 1508327732068 (13:55:32 GMT+0200 (Střední Evropa (letní čas)))
[Appium] Creating new AndroidDriver (v1.26.5) session
[Appium] Capabilities:
[Appium]   app: 'D:\\Prac\\JavaWorkspace\\TestAutomationPartners\\apk\\com.whatsapp.apk'
[Appium]   app-wait-activity: 'MainActivity'
[Appium]   platformVersion: '7.0'
[Appium]   platformName: 'Android'
[Appium]   deviceName: 'Galaxy S6'
[BaseDriver] The following capabilities were provided, but are not recognized by appium: app-wait-activity.
[BaseDriver] Session created with session id: 20bb4b00-509c-49dd-8796-e1d8ad0714dc
[AndroidDriver] Getting Java version
[AndroidDriver] Java version is: 9
[ADB] Checking whether adb is present
[ADB] Using adb.exe from D:\Prac\AndroidSDK\platform-tools\adb.exe
[AndroidDriver] Retrieving device list
[ADB] Trying to find a connected android device
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[AndroidDriver] Looking for a device with Android '7.0'
[ADB] Setting device id to 04157df4f2639124
[ADB] Getting device platform version
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'D:\Prac\AndroidSDK\platform-tools\adb.exe' with args: ["-P",5037,"-s","04157df4f2639124","shell","getprop","ro.build.version.release"]
[ADB] Current device property 'ro.build.version.release': 7.0
[AndroidDriver] Using device: 04157df4f2639124
[ADB] Checking whether adb is present
[ADB] Using adb.exe from D:\Prac\AndroidSDK\platform-tools\adb.exe
[ADB] Setting device id to 04157df4f2639124
[BaseDriver] Using local app 'D:\Prac\JavaWorkspace\TestAutomationPartners\apk\com.whatsapp.apk'
[AndroidDriver] Checking whether app is actually present
[AndroidDriver] Starting Android session
[ADB] Running 'D:\Prac\AndroidSDK\platform-tools\adb.exe' with args: ["-P",5037,"-s","04157df4f2639124","wait-for-device"]
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'D:\Prac\AndroidSDK\platform-tools\adb.exe' with args: ["-P",5037,"-s","04157df4f2639124","shell","echo","ping"]
[Logcat] Starting logcat capture
[AndroidDriver] Pushing settings apk to device...
[ADB] Getting install status for io.appium.settings
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'D:\Prac\AndroidSDK\platform-tools\adb.exe' with args: ["-P",5037,"-s","04157df4f2639124","shell","pm","list","packages","io.appium.settings"]
[ADB] App is installed
[ADB] Getting package info for io.appium.settings
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'D:\Prac\AndroidSDK\platform-tools\adb.exe' with args: ["-P",5037,"-s","04157df4f2639124","shell","dumpsys","package","io.appium.settings"]
[ADB] Checking whether aapt is present
[ADB] Using aapt.exe from D:\Prac\AndroidSDK\build-tools\25.0.3\aapt.exe
[ADB] The installed "io.appium.settings" package does not require upgrade (4 >= 4)
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'D:\Prac\AndroidSDK\platform-tools\adb.exe' with args: ["-P",5037,"-s","04157df4f2639124","shell","getprop","ro.build.version.sdk"]
[ADB] Current device property 'ro.build.version.sdk': 24
[ADB] Device API level: 24
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'D:\Prac\AndroidSDK\platform-tools\adb.exe' with args: ["-P",5037,"-s","04157df4f2639124","shell","dumpsys","package","io.appium.settings"]
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'D:\Prac\AndroidSDK\platform-tools\adb.exe' with args: ["-P",5037,"-s","04157df4f2639124","shell","pm","dump","io.appium.settings"]
[ADB] Got the following command chunks to execute: pm,grant,io.appium.settings,android.permission.WRITE_SETTINGS,;,pm,grant,io.appium.settings,android.permission.ACCESS_MOCK_LOCATION,;
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'D:\Prac\AndroidSDK\platform-tools\adb.exe' with args: ["-P",5037,"-s","04157df4f2639124","shell","pm","grant","io.appium.settings","android.permission.WRITE_SETTINGS",";","pm","grant","io.appium.settings","android.permission.ACCESS_MOCK_LOCATION",";"]
[ADB] Running 'D:\Prac\AndroidSDK\platform-tools\adb.exe' with args: ["-P",5037,"-s","04157df4f2639124","shell","pm","grant","io.appium.settings","android.permission.WRITE_SETTINGS",";","pm","grant","io.appium.settings","android.permission.ACCESS_MOCK_LOCATION",";"]
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'D:\Prac\AndroidSDK\platform-tools\adb.exe' with args: ["-P",5037,"-s","04157df4f2639124","shell","ps"]
[ADB] Device API level: 24
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'D:\Prac\AndroidSDK\platform-tools\adb.exe' with args: ["-P",5037,"-s","04157df4f2639124","shell","appops","set","io.appium.settings","android:mock_location","allow"]
[AndroidDriver] Pushing unlock helper app to device...
[ADB] Running 'D:\Prac\AndroidSDK\platform-tools\adb.exe' with args: ["-P",5037,"-s","04157df4f2639124","install","C:\\Users\\Jan\\AppData\\Local\\Programs\\appium-desktop\\resources\\app\\node_modules\\appium\\node_modules\\appium-unlock\\bin\\unlock_apk-debug.apk"]
[ADB] Running 'D:\Prac\AndroidSDK\platform-tools\adb.exe' with args: ["-P",5037,"-s","04157df4f2639124","install","C:\\Users\\Jan\\AppData\\Local\\Programs\\appium-desktop\\resources\\app\\node_modules\\appium\\node_modules\\appium-unlock\\bin\\unlock_apk-debug.apk"]
[ADB] Application 'C:\Users\Jan\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-unlock\bin\unlock_apk-debug.apk' already installed. Continuing.
[ADB] Getting device platform version
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'D:\Prac\AndroidSDK\platform-tools\adb.exe' with args: ["-P",5037,"-s","04157df4f2639124","shell","getprop","ro.build.version.release"]
[ADB] Current device property 'ro.build.version.release': 7.0
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'D:\Prac\AndroidSDK\platform-tools\adb.exe' with args: ["-P",5037,"-s","04157df4f2639124","shell","wm","size"]
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'D:\Prac\AndroidSDK\platform-tools\adb.exe' with args: ["-P",5037,"-s","04157df4f2639124","shell","getprop","ro.product.model"]
[ADB] Current device property 'ro.product.model': SM-G920F
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'D:\Prac\AndroidSDK\platform-tools\adb.exe' with args: ["-P",5037,"-s","04157df4f2639124","shell","getprop","ro.product.manufacturer"]
[ADB] Current device property 'ro.product.manufacturer': samsung
[AndroidDriver] Parsing package and activity from app manifest
[ADB] Checking whether aapt is present
[ADB] Using aapt.exe from D:\Prac\AndroidSDK\build-tools\25.0.3\aapt.exe
[ADB] Extracting package and launch activity from manifest
[ADB] badging package: com.whatsapp
[ADB] badging act: com.whatsapp.Main
[AndroidDriver] Parsed package and activity are: com.whatsapp/com.whatsapp.Main
[AndroidDriver] Remote apk path is /data/local/tmp/3ce651a86314b8d232a800345c91a23c.apk
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'D:\Prac\AndroidSDK\platform-tools\adb.exe' with args: ["-P",5037,"-s","04157df4f2639124","shell","ls","/data/local/tmp/3ce651a86314b8d232a800345c91a23c.apk"]
[AndroidDriver] Checking if app is installed
[ADB] Getting install status for com.whatsapp
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'D:\Prac\AndroidSDK\platform-tools\adb.exe' with args: ["-P",5037,"-s","04157df4f2639124","shell","pm","list","packages","com.whatsapp"]
[ADB] App is installed
[AndroidDriver] Apk is already on remote and installed, resetting
[AndroidDriver] Running fast reset (stop and clear)
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'D:\Prac\AndroidSDK\platform-tools\adb.exe' with args: ["-P",5037,"-s","04157df4f2639124","shell","am","force-stop","com.whatsapp"]
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'D:\Prac\AndroidSDK\platform-tools\adb.exe' with args: ["-P",5037,"-s","04157df4f2639124","shell","pm","clear","com.whatsapp"]
[AndroidDriver] Extracting strings from apk D:\Prac\JavaWorkspace\TestAutomationPartners\apk\com.whatsapp.apk undefined C:\Users\Jan\AppData\Local\Temp\com.whatsapp
[ADB] Extracting strings for language: default
[ADB] Device API level: 24
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'D:\Prac\AndroidSDK\platform-tools\adb.exe' with args: ["-P",5037,"-s","04157df4f2639124","shell","getprop","persist.sys.locale"]
[ADB] Current device property 'persist.sys.locale': cs-CZ
[ADB] Reading strings from converted strings.json
[ADB] Running 'D:\Prac\AndroidSDK\platform-tools\adb.exe' with args: ["-P",5037,"-s","04157df4f2639124","push","C:\\Users\\Jan\\AppData\\Local\\Temp\\com.whatsapp\\strings.json","/data/local/tmp"]
[AndroidBootstrap] Watching for bootstrap disconnect
[ADB] Forwarding system: 4724 to device: 4724
[ADB] Running 'D:\Prac\AndroidSDK\platform-tools\adb.exe' with args: ["-P",5037,"-s","04157df4f2639124","forward","tcp:4724","tcp:4724"]
[UiAutomator] Starting UiAutomator
[UiAutomator] Moving to state 'starting'
[UiAutomator] Parsing uiautomator jar
[UiAutomator] Found jar name: 'AppiumBootstrap.jar'
[ADB] Running 'D:\Prac\AndroidSDK\platform-tools\adb.exe' with args: ["-P",5037,"-s","04157df4f2639124","push","C:\\Users\\Jan\\AppData\\Local\\Programs\\appium-desktop\\resources\\app\\node_modules\\appium\\node_modules\\appium-android-bootstrap\\bootstrap\\bin\\AppiumBootstrap.jar","/data/local/tmp/"]
[ADB] Attempting to kill all uiautomator processes
[ADB] Getting all processes with uiautomator
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'D:\Prac\AndroidSDK\platform-tools\adb.exe' with args: ["-P",5037,"-s","04157df4f2639124","shell","ps"]
[ADB] No uiautomator process found to kill, continuing...
[UiAutomator] Starting UIAutomator
[ADB] Creating ADB subprocess with args: ["-P",5037,"-s","04157df4f2639124","shell","uiautomator","runtest","AppiumBootstrap.jar","-c","io.appium.android.bootstrap.Bootstrap","-e","pkg","com.whatsapp","-e","disableAndroidWatchers",false,"-e","acceptSslCerts",false]
[UiAutomator] Moving to state 'online'
[AndroidBootstrap] Android bootstrap socket is now connected
[ADB] Getting connected devices...
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] json loading complete.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Registered crash watchers.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Client connected
[ADB] 1 device(s) connected
[ADB] Running 'D:\Prac\AndroidSDK\platform-tools\adb.exe' with args: ["-P",5037,"-s","04157df4f2639124","shell","dumpsys","window"]
[AndroidDriver] Screen already unlocked, doing nothing
[ADB] Device API level: 24
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'D:\Prac\AndroidSDK\platform-tools\adb.exe' with args: ["-P",5037,"-s","04157df4f2639124","shell","am","start","-W","-n","com.whatsapp/com.whatsapp.Main","-S"]
[ADB] Waiting up to 20000ms for activity matching pkg: 'com.whatsapp' and activity: 'com.whatsapp.Main' to be focused
[ADB] Possible activities, to be checked: 'com.whatsapp.Main'
[ADB] Getting focused package and activity
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'D:\Prac\AndroidSDK\platform-tools\adb.exe' with args: ["-P",5037,"-s","04157df4f2639124","shell","dumpsys","window","windows"]
[ADB] Found package: 'com.whatsapp' and fully qualified activity name : 'com.whatsapp.registration.EULA'

现在有

[ADB] Incorrect package and activity. Retrying.
    [ADB] Getting focused package and activity
    [ADB] Getting connected devices...
    [ADB] 1 device(s) connected
    [ADB] Running 'D:\Prac\AndroidSDK\platform-tools\adb.exe' with args: ["-P",5037,"-s","04157df4f2639124","shell","dumpsys","window","windows"]
    [ADB] Found package: 'com.whatsapp' and fully qualified activity name : 'com.whatsapp.registration.EULA'

很多时候...

[ADB] Incorrect package and activity. Retrying.
[ADB] Error: Error occured while starting App. Original error: 'com.whatsapp.Main' never started
    at Object.wrappedLogger.errorAndThrow (C:\Users\Jan\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-support\lib\logging.js:63:13)
    at ADB.callee$0$0$ (C:\Users\Jan\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-adb\lib\tools\apk-utils.js:101:9)
    at tryCatch (C:\Users\Jan\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\Jan\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (C:\Users\Jan\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
    at GeneratorFunctionPrototype.invoke (C:\Users\Jan\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
 Error: Error occured while starting App. Original error: 'com.whatsapp.Main' never started
    at Object.wrappedLogger.errorAndThrow (C:\Users\Jan\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-support\lib\logging.js:63:13)
    at ADB.callee$0$0$ (C:\Users\Jan\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-adb\lib\tools\apk-utils.js:101:9)
    at tryCatch (C:\Users\Jan\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\Jan\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (C:\Users\Jan\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
    at GeneratorFunctionPrototype.invoke (C:\Users\Jan\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
[AndroidDriver] Shutting down Android driver
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'D:\Prac\AndroidSDK\platform-tools\adb.exe' with args: ["-P",5037,"-s","04157df4f2639124","shell","am","force-stop","com.whatsapp"]
[ADB] Pressing the HOME button
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'D:\Prac\AndroidSDK\platform-tools\adb.exe' with args: ["-P",5037,"-s","04157df4f2639124","shell","input","keyevent",3]
[AndroidBootstrap] Sending command to android: {"cmd":"shutdown"}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {"cmd":"shutdown"}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type SHUTDOWN
[AndroidBootstrap] Received command result from bootstrap
[UiAutomator] Shutting down UiAutomator
[UiAutomator] Moving to state 'stopping'
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":"OK, shutting down"}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Closed client connection
[AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: numtests=1
[AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: stream=.
[AndroidBootstrap] [UIAUTO STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
[UiAutomator] UiAutomator shut down normally
[UiAutomator] Moving to state 'stopped'
[ADB] Attempting to kill all uiautomator processes
[ADB] Getting all processes with uiautomator
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'D:\Prac\AndroidSDK\platform-tools\adb.exe' with args: ["-P",5037,"-s","04157df4f2639124","shell","ps"]
[ADB] No uiautomator process found to kill, continuing...
[UiAutomator] Moving to state 'stopped'
[Logcat] Stopping logcat capture
[ADB] Getting connected devices...
[ADB] 1 device(s) connected
[ADB] Running 'D:\Prac\AndroidSDK\platform-tools\adb.exe' with args: ["-P",5037,"-s","04157df4f2639124","shell","am","force-stop","io.appium.unlock"]
[AndroidDriver] Not cleaning generated files. Add `clearSystemFiles` capability if wanted.
[MJSONWP] Encountered internal error running command: Error: Error occured while starting App. Original error: 'com.whatsapp.Main' never started
    at Object.wrappedLogger.errorAndThrow (C:\Users\Jan\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-support\lib\logging.js:63:13)
    at ADB.callee$0$0$ (C:\Users\Jan\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\appium-adb\lib\tools\apk-utils.js:101:9)
    at tryCatch (C:\Users\Jan\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\Jan\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (C:\Users\Jan\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
    at GeneratorFunctionPrototype.invoke (C:\Users\Jan\AppData\Local\Programs\appium-desktop\resources\app\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
[HTTP] <-- POST /wd/hub/session 500 64685 ms - 220 

共有1个答案

戚繁
2023-03-14

如果您提供应用程序功能,则无需指定功能appPackage和appActivity

如果您已经在我们的设备中预安装了应用程序,那么您可以启动具有appPackage和appActivity功能的应用程序

File app_apk = new File("/Users/Yash/Desktop/APK/Sample.apk");
capabilities.setCapability("app", file.getAbsolutePath());

无需提供appPackage

假设应用程序已安装,您想启动它

capabilities.setCapability("appPackage", "Your-appPackage-name");
capabilities.setCapability("appActivity", "Your-appActivity-name");

如何获取应用程序appPackage

确保adb已连接

adb shell "dumpsys window windows | grep -E 'mCurrentFocus|mFocusedApp'"

时钟应用的示例输出

mCurrentFocus=Window{ce2e95b u0 com.google.android.deskclock/com.android.deskclock.DeskClock}
mFocusedApp=AppWindowToken{3cac5b0 token=Token{c58d7d6 ActivityRecord{74c3ff1 u0 com.google.android.deskclock/com.android.deskclock.DeskClock t80}}}

从上面的输出我们可以找到appPackage和app activity app package/app activity

com.google.android.deskclock/com.android.deskclock.DeskClock
appPackage = com.google.android.deskclock
appActivity = com.android.deskclock.DeskClock

如何检查我的应用程序包/应用程序活动是否正确?

试试这个

adb shell am start -n appPackage/appActivity
adb shell am start -n com.google.android.deskclock/com.android.deskclock.DeskClock

应启动时钟应用程序

伙计,我认为通过以上任何一种方法,你都可以解决你的问题。否则请告诉我。

 类似资料:
  • 我在intellij上启动spring boot应用程序时遇到问题,它失败了,并显示以下消息:与目标VM断开连接,地址:'127.0.0.1:49784',传输:'socket' 过程结束,退出代码为255。以前有人遇到过这种情况吗?

  • 我有一个Spring Boot应用程序,其中有一个Kafka消费者和生产者。还有一个bean来创建主题。 我的Spring Boot应用程序和Kafka都是在Kubernetes的Docker启动的。有时Spring Boot应用程序在Kafka pod启动之前就启动了,因此无法启动,因为用户无法连接(参见stacktrace)。 有没有一种方法可以让我的应用程序以弹性的方式启动?例如,消费者应该

  • 我有一个spring启动应用程序,我需要通过进入文件夹目录并通过命令行启动我的web应用程序来启动它。我有一门课叫应用。java及其内部代码如下所示。 我设置了类路径,然后试图运行命令"",但我得到了这个错误消息""

  • 以下是错误: 下面是我的pom.xml文件: 这是我的主课:

  • 问题内容: 我有一个Java应用程序。 该应用程序具有一个设置,该设置决定该应用程序是否在启动时启动。 目前,我可以通过在“启动项目”文件夹中放置/删除快捷方式来实现此目的。 但是,我想知道是否有更好的方法来处理此行为。 编辑 是的,它是Windows。抱歉,之前没有清除该内容。 该应用程序具有一个用户可以在其中触发动作的UI,并且该应用程序在运行时会定期在后台运行一些任务。 @Peter,如何在

  • 我正在使用此代码,无法在我的移动设备上启动应用程序 TLDR: 原始错误:活动名称'。用于启动应用程序的SplashActivity不存在或无法启动!确保它存在并且是可启动的活动 下面是我的错误日志 log4j:WARN找不到记录器(org.apache.http.client.protocol.RequestAddCookies)的追加器。log4j:警告请正确初始化log4j系统。log4j: