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

问题描述:

通过Appium服务器执行代码会导致应用程序启动几秒钟。然后程序停止工作出现错误:通过Appium启动(WhatsApp)移动应用程序导致“'com.whatsapp.Main'从未启动”错误

Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: An unknown server-side error occurred while processing the command. Original error: Error occured while starting App. Original error: 'com.whatsapp.Main' never started (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 0 milliseconds Build info: version: '3.3.1', revision: '5234b32', time: '2017-03-10 09:04:52 -0800' System info: host: 'DESKTOP-7P0AKLE', ip: '172.20.167.164', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '9' Driver info: driver.version: RemoteWebDriver at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:488) at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:216) at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:168) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:367) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:113) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:604) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:244) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:131) at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:158) at app.TestManager.createAppiumWebDriver(TestManager.java:227) at app.TestManager.runTests(TestManager.java:167) at app.TestManager.run(TestManager.java:43) at app.Launcher.main(Launcher.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"); 
    //??? 

从我能够在我自己的研究这个问题: 我想我应该等待“主”活动运行。我以为我是通过添加app-wait-activity功能来做到这一点的。但没有结果...... (另外,应用程序启动几秒钟,让“主”的活动应该已经运行 - shouldn't吗?)

下面是从Appium服务器日志:

Appium log

,完成记录在这里:

> 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 

如果您提供的应用能力那么有没有需要指定capabilties appPackageappActivity

柜面你有预 - 在我们的设备中安装应用程序,然后您可以启动应用程序的功能appPackageappActivity

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

无需提供appPackage & appActivity现在

可以说是安装了应用程序要启动它

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

如何获取应用程序appPackage &应用活动?

使连接确保亚行>打开设备中的应用>输入时钟应用

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}}} 

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

样本输出从上面的输出,我们可以找出appPackage应用活动 appPackage/appActivity

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

如何检查我的appPackage/appActivity是否正确?

试试这个

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

应该启动时钟应用

男人,我想通过以下任何,你将能够解决您的问题上述方法。否则让我知道。