appium启动app报错

appium启动公司app报错如下,但是启动像企业微信、微信都是没有问题的;

remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: Cannot start the 'com.****.salesman.in' application. Visit https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/activity-startup.md for troubleshooting. Original error: Error executing adbExec. Original error: 'Command 'D:\software\Android\platform-tools\adb.exe -P 5037 -s 127.0.0.1:21503 shell am start -W -n com.****.salesman.in/.loader.a.ActivityN1STNTS1 -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000' timed out after 20000ms'. Try to increase the 20000ms adb execution timeout represented by 'adbExecTimeout' capability
at getResponseForW3CError (C:Program FilesAppium esourcesapp ode_modulesappium ode_modulesappium-base-driverlibprotocolerrors.js:804:9)
at asyncHandler (C:Program FilesAppium esourcesapp ode_modulesappium ode_modulesappium-base-driverlibprotocolprotocol.js:384:37)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: '**-00234109', ip: '*****', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_181'
Driver info: driver.version: AndroidDriver
at io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:216)
at io.appium.java_client.remote.AppiumCommandExecutor.createSession(AppiumCommandExecutor.java:225)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:247)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:41)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
at io.appium.java_client.AppiumDriver.startSession(AppiumDriver.java:338)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at io.appium.java_client.DefaultGenericMobileDriver.<init>(DefaultGenericMobileDriver.java:37)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:89)
at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:99)
at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:96)
at AppiumTest.main(AppiumTest.java:26)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:193)
... 14 more
Caused by: org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Cannot start the 'com.****.salesman.in' application. Visit https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/activity-startup.md for troubleshooting. Original error: Error executing adbExec. Original error: 'Command 'D:\software\Android\platform-tools\adb.exe -P 5037 -s 127.0.0.1:21503 shell am start -W -n com.****.salesman.in/.loader.a.ActivityN1STNTS1 -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000' timed out after 20000ms'. Try to increase the 20000ms adb execution timeout represented by 'adbExecTimeout' capability
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: '**-00234109', ip: '****', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_181'
Driver info: driver.version: AndroidDriver
remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: Cannot start the 'com.****.salesman.in' application. Visit https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/activity-startup.md for troubleshooting. Original error: Error executing adbExec. Original error: 'Command 'D:\software\Android\platform-tools\adb.exe -P 5037 -s 127.0.0.1:21503 shell am start -W -n com.****.salesman.in/.loader.a.ActivityN1STNTS1 -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000' timed out after 20000ms'. Try to increase the 20000ms adb execution timeout represented by 'adbExecTimeout' capability
at getResponseForW3CError (C:Program FilesAppium esourcesapp ode_modulesappium ode_modulesappium-base-driverlibprotocolerrors.js:804:9)
at asyncHandler (C:Program FilesAppium esourcesapp ode_modulesappium ode_modulesappium-base-driverlibprotocolprotocol.js:384:37)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$errorHandler$0(W3CHandshakeResponse.java:62)
at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:126)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:128)
... 19 more

通过adb shell dumpsys activity | find "mFocusedActivity"获取appPackage和appActivity

网上的一些教程appActivity就是“.loader.a.ActivityN1STNTS1”,这样启动就会报上面的错误;

原因appActivity获取错误,应该是如下操作获取

应用的入口activity,通过此属性,可以开启app, 使用aapt.exe 获取appActivity

aapt.exe(Android Asset Packaging Tool), 在SDK的build-tools目录下。命令行进入aapt.exe所在目录,执行aapt dump badging C:UsersAdministratorDesktopin-**-1.0.72-0128-171636.apk,就可以获取到appActivity,“launchable-activity: name='com.**.**.host.WelcomeActivity'  label='' icon=''”

原文地址:https://www.cnblogs.com/cjy-blog/p/14365191.html