appium Start Session 时报错,错误信息如下:
版本信息:
Appium v1.17.1
android 9
JDK 1.8
配置信息如图:
详细错误信息:
An unknown server-side error occurred while processing the command. Original error: Cannot start the 'com.uu.trip.driver' 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 'F:\AS_SDK\platform-tools\adb.exe -P 5037 -s 8fbccc25 shell am start -W -n com.uu.trip.driver/com.uu.trip.driver.ui.activity.HomeActivity -S' exited with code 255'; Stderr: 'Security exception: Permission Denial: starting Intent { flg=0x10000000 cmp=com.uu.trip.driver/.ui.activity.HomeActivity } from null (pid=12233, uid=2000) not exported from uid 10362 java.lang.SecurityException: Permission Denial: starting Intent { flg=0x10000000 cmp=com.uu.trip.driver/.ui.activity.HomeActivity } from null (pid=12233, uid=2000) not exported from uid 10362 at com.android.server.am.ActivityStackSupervisor.checkStartAnyActivityPermission(ActivityStackSupervisor.java:1864) at com.android.server.am.ActivityStarter.startActivity(ActivityStarter.java:751) at com.android.server.am.ActivityStarter.startActivity(ActivityStarter.java:552) at com.android.server.am.ActivityStarter.startActivityMayWait(ActivityStarter.java:1214) at com.android.server.am.ActivityStarter.execute(ActivityStarter.java:494) at com.android.server.am.ActivityManagerService.startActivityAndWait(ActivityManagerService.java:5490) at com.android.server.am.ActivityManagerShellCommand.runStartActivity(ActivityManagerShellCommand.java:474) at com.android.server.am.ActivityManagerShellCommand.onCommand(ActivityManagerShellCommand.java:161) at android.os.ShellCommand.exec(ShellCommand.java:103) at com.android.server.am.ActivityManagerService.onShellCommand(ActivityManagerService.java:16647) at android.os.Binder.shellCommand(Binder.java:634) at android.os.Binder.onTransact(Binder.java:532) at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:3538) at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3394) at android.os.Binder.execTransact(Binder.java:735)'; Code: '255'
appium 的运行日志:
[Appium] Non-default server args:
[Appium] allowInsecure: {
[Appium] }
[Appium] denyInsecure: {
[Appium] }
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[HTTP] --> GET /wd/hub/sessions
[HTTP] {}
[GENERIC] Calling AppiumDriver.getSessions() with args: []
[GENERIC] Responding to client with driver.getSessions() result: []
[HTTP] <-- GET /wd/hub/sessions 200 5 ms - 40
[HTTP]
[HTTP] --> POST /wd/hub/session
[HTTP] {"desiredCapabilities":{"appActivity":"com.uu.goods.driver.ui.activity.HomeActivity","appPackage":"com.uu.goods.driver","automationName":"UiAutomator1","deviceName":"8fbccc25","platformName":"Android","platformVersion":"9","newCommandTimeout":0,"connectHardwareKeyboard":true}}
[MJSONWP] Calling AppiumDriver.createSession() with args: [{"appActivity":"com.uu.goods.driver.ui.activity.HomeActivity","appPackage":"com.uu.goods.driver","automationName":"UiAutomator1","deviceName":"8fbccc25","platformName":"Android","platformVersion":"9","newCommandTimeout":0,"connectHardwareKeyboard":true},null,null]
[BaseDriver] Event 'newSessionRequested' logged at 1595410645672 (17:37:25 GMT+0800 (中国标准时间))
[Appium] Appium v1.17.1 creating new AndroidDriver (v4.26.1) session
[BaseDriver] Creating session with MJSONWP desired capabilities: {
[BaseDriver] "appActivity": "com.uu.goods.driver.ui.activity.HomeActivity",
[BaseDriver] "appPackage": "com.uu.goods.driver",
[BaseDriver] "automationName": "UiAutomator1",
[BaseDriver] "deviceName": "8fbccc25",
[BaseDriver] "platformName": "Android",
[BaseDriver] "platformVersion": "9",
[BaseDriver] "newCommandTimeout": 0,
[BaseDriver] "connectHardwareKeyboard": true
[BaseDriver] }
[BaseDriver] The following capabilities were provided, but are not recognized by Appium:
[BaseDriver] connectHardwareKeyboard
[BaseDriver] Session created with session id: c581acb8-ed85-40da-8749-99d9c20adc2f
[ADB] Found 1 'build-tools' folders under 'F:\AS_SDK' (newest first):
[ADB] F:/AS_SDK/build-tools/30.0.1
[ADB] Using 'adb.exe' from 'F:\AS_SDK\platform-tools\adb.exe'
[AndroidDriver] Retrieving device list
[ADB] Trying to find a connected android device
[ADB] Getting connected devices...
[ADB] Connected devices: [{"udid":"8fbccc25","state":"device"}]
[AndroidDriver] Looking for a device with Android '9.0.0'
[ADB] Setting device id to 8fbccc25
[ADB] Getting device platform version
[ADB] Running 'F:\AS_SDK\platform-tools\adb.exe -P 5037 -s 8fbccc25 shell getprop ro.build.version.release'
[ADB] Current device property 'ro.build.version.release': 9
[AndroidDriver] Using device: 8fbccc25
[ADB] Using 'adb.exe' from 'F:\AS_SDK\platform-tools\adb.exe'
[ADB] Setting device id to 8fbccc25
[ADB] Running 'F:\AS_SDK\platform-tools\adb.exe -P 5037 -s 8fbccc25 shell getprop ro.build.version.sdk'
[ADB] Current device property 'ro.build.version.sdk': 28
[ADB] Getting device platform version
[ADB] Running 'F:\AS_SDK\platform-tools\adb.exe -P 5037 -s 8fbccc25 shell getprop ro.build.version.release'
[ADB] Current device property 'ro.build.version.release': 9
[ADB] Device API level: 28
[AndroidDriver] Consider setting 'automationName' capability to 'uiautomator2' on Android >= 6, since UIAutomator framework is not maintained anymore by the OS vendor.
[AndroidDriver] App file was not listed, instead we're going to run com.uu.goods.driver directly on the device
[AndroidDriver] Checking whether package is present on the device
[ADB] Running 'F:\AS_SDK\platform-tools\adb.exe -P 5037 -s 8fbccc25 shell pm list packages com.uu.goods.driver'
[AndroidDriver] Starting Android session
[ADB] Running 'F:\AS_SDK\platform-tools\adb.exe -P 5037 -s 8fbccc25 wait-for-device'
[ADB] Running 'F:\AS_SDK\platform-tools\adb.exe -P 5037 -s 8fbccc25 shell echo ping'
[AndroidDriver] Pushing settings apk to device...
[ADB] Getting install status for io.appium.settings
[ADB] Running 'F:\AS_SDK\platform-tools\adb.exe -P 5037 -s 8fbccc25 shell dumpsys package io.appium.settings'
[ADB] 'io.appium.settings' is installed
[ADB] Getting package info for 'io.appium.settings'
[ADB] Running 'F:\AS_SDK\platform-tools\adb.exe -P 5037 -s 8fbccc25 shell dumpsys package io.appium.settings'
[ADB] The version name of the installed 'io.appium.settings' is greater or equal to the application version name ('3.1.0' >= '3.1.0')
[ADB] There is no need to install/upgrade 'C:\Users\Administrator\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\io.appium.settings\apks\settings_apk-debug.apk'
[ADB] Getting IDs of all 'io.appium.settings' processes
[ADB] Running 'F:\AS_SDK\platform-tools\adb.exe -P 5037 -s 8fbccc25 shell 'pgrep --help; echo $?''
[ADB] Running 'F:\AS_SDK\platform-tools\adb.exe -P 5037 -s 8fbccc25 shell pgrep -f io.appium.settings'
[AndroidDriver] io.appium.settings is already running. There is no need to reset its permissions.
[ADB] Running 'F:\AS_SDK\platform-tools\adb.exe -P 5037 -s 8fbccc25 shell appops set io.appium.settings android:mock_location allow'
[Logcat] Starting logcat capture
[ADB] Getting device platform version
[ADB] Running 'F:\AS_SDK\platform-tools\adb.exe -P 5037 -s 8fbccc25 shell getprop ro.build.version.release'
[ADB] Current device property 'ro.build.version.release': 9
[ADB] Running 'F:\AS_SDK\platform-tools\adb.exe -P 5037 -s 8fbccc25 shell wm size'
[ADB] Running 'F:\AS_SDK\platform-tools\adb.exe -P 5037 -s 8fbccc25 shell getprop ro.product.model'
[ADB] Current device property 'ro.product.model': Redmi Note 7
[ADB] Running 'F:\AS_SDK\platform-tools\adb.exe -P 5037 -s 8fbccc25 shell getprop ro.product.manufacturer'
[ADB] Current device property 'ro.product.manufacturer': Xiaomi
[AndroidDriver] No app sent in, not parsing package/activity
[AndroidDriver] No app capability. Assuming it is already on the device
[ADB] Getting install status for com.uu.goods.driver
[ADB] Running 'F:\AS_SDK\platform-tools\adb.exe -P 5037 -s 8fbccc25 shell dumpsys package com.uu.goods.driver'
[ADB] 'com.uu.goods.driver' is installed
[ADB] Running 'F:\AS_SDK\platform-tools\adb.exe -P 5037 -s 8fbccc25 shell am force-stop com.uu.goods.driver'
[ADB] Running 'F:\AS_SDK\platform-tools\adb.exe -P 5037 -s 8fbccc25 shell pm clear com.uu.goods.driver'
[AndroidDriver] Performed fast reset on the installed 'com.uu.goods.driver' application (stop and clear)
[AndroidBootstrap] Watching for bootstrap disconnect
[ADB] Forwarding system: 4724 to device: 4724
[ADB] Running 'F:\AS_SDK\platform-tools\adb.exe -P 5037 -s 8fbccc25 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 'F:\AS_SDK\platform-tools\adb.exe -P 5037 -s 8fbccc25 shell mkdir -p /data/local'
[ADB] Running 'F:\AS_SDK\platform-tools\adb.exe -P 5037 -s 8fbccc25 push C:\Users\Administrator\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-android-driver\bootstrap\bin\AppiumBootstrap.jar /data/local/tmp/'
[ADB] Attempting to kill all uiautomator processes
[ADB] Getting IDs of all 'uiautomator' processes
[ADB] Running 'F:\AS_SDK\platform-tools\adb.exe -P 5037 -s 8fbccc25 shell pgrep -f uiautomator'
[ADB] No 'uiautomator' process has been found
[UiAutomator] Starting UIAutomator
[ADB] Creating ADB subprocess with args: ["-P",5037,"-s","8fbccc25","shell","uiautomator","runtest","AppiumBootstrap.jar","-c","io.appium.android.bootstrap.Bootstrap","-e","pkg","com.uu.goods.driver","-e","disableAndroidWatchers",false,"-e","acceptSslCerts",false]
[UiAutomator] Moving to state 'online'
[AndroidBootstrap] Android bootstrap socket is now connected
[ADB] Running 'F:\AS_SDK\platform-tools\adb.exe -P 5037 -s 8fbccc25 shell dumpsys window'
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Registered crash watchers.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Client connected
[AndroidDriver] Screen already unlocked, doing nothing
[ADB] Running 'F:\AS_SDK\platform-tools\adb.exe -P 5037 -s 8fbccc25 shell am start -W -n com.uu.goods.driver/com.uu.goods.driver.ui.activity.HomeActivity -S'
[AndroidDriver] Shutting down Android driver
[ADB] Running 'F:\AS_SDK\platform-tools\adb.exe -P 5037 -s 8fbccc25 shell am force-stop com.uu.goods.driver'
[ADB] Pressing the HOME button
[ADB] Running 'F:\AS_SDK\platform-tools\adb.exe -P 5037 -s 8fbccc25 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] [BOOTSTRAP LOG] [debug] Returning result: {"status":0,"value":"OK, shutting down"}
[AndroidBootstrap] Received command result from bootstrap
[UiAutomator] Shutting down UiAutomator
[UiAutomator] Moving to state 'stopping'
[UiAutomator] UiAutomator shut down normally
[UiAutomator] Moving to state 'stopped'
[ADB] Attempting to kill all uiautomator processes
[ADB] Getting IDs of all 'uiautomator' processes
[ADB] Running 'F:\AS_SDK\platform-tools\adb.exe -P 5037 -s 8fbccc25 shell pgrep -f uiautomator'
[ADB] No 'uiautomator' process has been found
[UiAutomator] Moving to state 'stopped'
[Logcat] Stopping logcat capture
[ADB] Running 'F:\AS_SDK\platform-tools\adb.exe -P 5037 -s 8fbccc25 shell am force-stop io.appium.unlock'
[BaseDriver] Event 'newSessionStarted' logged at 1595410653238 (17:37:33 GMT+0800 (中国标准时间))
[MJSONWP] Encountered internal error running command: Error: Cannot start the 'com.uu.goods.driver' 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 'F:\AS_SDK\platform-tools\adb.exe -P 5037 -s 8fbccc25 shell am start -W -n com.uu.goods.driver/com.uu.goods.driver.ui.activity.HomeActivity -S' exited with code 255'; Stderr: 'Security exception: Permission Denial: starting Intent { flg=0x10000000 cmp=com.uu.goods.driver/.ui.activity.HomeActivity } from null (pid=26422, uid=2000) not exported from uid 10361
[MJSONWP]
[MJSONWP] java.lang.SecurityException: Permission Denial: starting Intent { flg=0x10000000 cmp=com.uu.goods.driver/.ui.activity.HomeActivity } from null (pid=26422, uid=2000) not exported from uid 10361
[MJSONWP] at com.android.server.am.ActivityStackSupervisor.checkStartAnyActivityPermission(ActivityStackSupervisor.java:1864)
[MJSONWP] at com.android.server.am.ActivityStarter.startActivity(ActivityStarter.java:751)
[MJSONWP] at com.android.server.am.ActivityStarter.startActivity(ActivityStarter.java:552)
[MJSONWP] at com.android.server.am.ActivityStarter.startActivityMayWait(ActivityStarter.java:1214)
[MJSONWP] at com.android.server.am.ActivityStarter.execute(ActivityStarter.java:494)
[MJSONWP] at com.android.server.am.ActivityManagerService.startActivityAndWait(ActivityManagerService.java:5490)
[MJSONWP] at com.android.server.am.ActivityManagerShellCommand.runStartActivity(ActivityManagerShellCommand.java:474)
[MJSONWP] at com.android.server.am.ActivityManagerShellCommand.onCommand(ActivityManagerShellCommand.java:161)
[MJSONWP] at android.os.ShellCommand.exec(ShellCommand.java:103)
[MJSONWP] at com.android.server.am.ActivityManagerService.onShellCommand(ActivityManagerService.java:16647)
[MJSONWP] at android.os.Binder.shellCommand(Binder.java:634)
[MJSONWP] at android.os.Binder.onTransact(Binder.java:532)
[MJSONWP] at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:3538)
[MJSONWP] at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3394)
[MJSONWP] at android.os.Binder.execTransact(Binder.java:735)'; Code: '255'
[MJSONWP] at ADB.startApp (C:\Users\Administrator\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-adb\lib\tools\apk-utils.js:165:11)
[MJSONWP] Destroying socket connection
[HTTP] <-- POST /wd/hub/session 500 7585 ms - 2270
[HTTP]
[HTTP] --> DELETE /wd/hub/session
[HTTP] {}
[HTTP] No route found. Setting content type to 'text/plain'
[HTTP] <-- DELETE /wd/hub/session 404 8 ms - 57
[HTTP]
已经尝试过的解决方案:
增加 android:exported="true" 属性,未解决,报错信息仍然一致
更改 automationName 属性值
通过 adb shell monkey -p com.uu.trip.driver -v 1 软件启动成功,并得到以下信息