Appium 大佬帮忙看下明明参数设置的包名和 activity 都是正确的却启动不了

Diky · 2022年07月05日 · 最后由 Diky 回复于 2022年07月05日 · 6417 次阅读

代码:

from time import sleep
from selenium import webdriver
import appium.webdriver

class GetDriver(object):
    driver = None
    @classmethod
    def get_app_driver(cls):
        if cls.driver is None:
            disired_cap = {}
            disired_cap['platformName'] = 'Android'
            disired_cap['platformVersion'] = '10'
            disired_cap['deviceName'] = 'VBJDU18522004463'
            disired_cap['noReset'] = True
            disired_cap['appPackage'] = 'com.netease.newsreader.activity'
            disired_cap['appActivity'] = 'com.netease.nr.phone.main.MainActivity'
            cls.driver = appium.webdriver.Remote("http://127.0.0.1:4723/wd/hub",disired_cap)
        return cls.driver

    @classmethod
    def quit_app_driver(cls):
        if cls.driver:
            cls.driver.quit()
            cls.driver = None

if __name__ == '__main__':
    GetDriver.get_app_driver()
    sleep(3)
    GetDriver.quit_app_driver()

adb 获取的 activity:

报错:

[Appium] Welcome to Appium v1.15.1
[Appium] Non-default server args:
[Appium]   address: 127.0.0.1
[Appium]   allowInsecure: {
[Appium]   }
[Appium]   denyInsecure: {
[Appium]   }
[Appium] Appium REST http interface listener started on 127.0.0.1:4723
[HTTP] --> POST /wd/hub/session
[HTTP] {"capabilities":{"alwaysMatch":{"platformName":"Android","appium:platformVersion":"10","appium:deviceName":"VBJDU18522004463","appium:noReset":true,"appium:appPackage":"com.netease.newsreader.activity","appium:appActivity":"com.netease.nr.phone.main.MainActivity"},"firstMatch":[{}]},"desiredCapabilities":{"platformName":"Android","platformVersion":"10","deviceName":"VBJDU18522004463","noReset":true,"appPackage":"com.netease.newsreader.activity","appActivity":"com.netease.nr.phone.main.MainActivity"}}
[W3C] Calling AppiumDriver.createSession() with args: [{"platformName":"Android","platformVersion":"10","deviceName":"VBJDU18522004463","noReset":true,"appPackage":"com.netease.newsreader.activity","appActivity":"com.netease.nr.phone.main.MainActivity"},null,{"alwaysMatch":{"platformName":"Android","appium:platformVersion":"10","appium:deviceName":"VBJDU18522004463","appium:noReset":true,"appium:appPackage":"com.netease.newsreader.activity","appium:appActivity":"com.netease.nr.phone.main.MainActivity"},"firstMatch":[{}]}]
[BaseDriver] Event 'newSessionRequested' logged at 1656953991671 (00:59:51 GMT+0800 (中国标准时间))
[Appium] 
[Appium] ======================================================================
[Appium]   DEPRECATION WARNING:
[Appium] 
[Appium]   The 'automationName' capability was not provided in the desired 
[Appium]   capabilities for this Android session
[Appium] 
[Appium]   Setting 'automationName=UiAutomator2' by default and using the 
[Appium]   UiAutomator2 Driver
[Appium] 
[Appium]   The next major version of Appium (2.x) will **require** the 
[Appium]   'automationName' capability to be set for all sessions on all 
[Appium]   platforms
[Appium] 
[Appium]   In previous versions (Appium <= 1.13.x), the default was 
[Appium]   'automationName=UiAutomator1'
[Appium] 
[Appium]   If you wish to use that automation instead of UiAutomator2, please 
[Appium]   add 'automationName=UiAutomator1' to your desired capabilities
[Appium] 
[Appium]   For more information about drivers, please visit 
[Appium]   http://appium.io/docs/en/about-appium/intro/ and explore the 
[Appium]   'Drivers' menu
[Appium] 
[Appium] ======================================================================
[Appium] 
[Appium] Appium v1.15.1 creating new AndroidUiautomator2Driver (v1.37.2) session
[BaseDriver] W3C capabilities and MJSONWP desired capabilities were provided
[BaseDriver] Creating session with W3C capabilities: {
[BaseDriver]   "alwaysMatch": {
[BaseDriver]     "platformName": "Android",
[BaseDriver]     "appium:platformVersion": "10",
[BaseDriver]     "appium:deviceName": "VBJDU18522004463",
[BaseDriver]     "appium:noReset": true,
[BaseDriver]     "appium:appPackage": "com.netease.newsreader.activity",
[BaseDriver]     "appium:appActivity": "com.netease.nr.phone.main.MainActivity"
[BaseDriver]   },
[BaseDriver]   "firstMatch": [
[BaseDriver]     {}
[BaseDriver]   ]
[BaseDriver] }
[BaseDriver] Session created with session id: ca82b371-acd7-4662-a1c4-f7167fe79860
[UiAutomator2] Starting 'com.netease.newsreader.activity' directly on the device
[ADB] Using 'adb.exe' from 'D:\android_sdk_test\android_sdk_test\platform-tools\adb.exe'
[AndroidDriver] Retrieving device list
[ADB] Trying to find a connected android device
[ADB] Getting connected devices...
[ADB] Connected devices: [{"udid":"VBJDU18522004463","state":"device"}]
[AndroidDriver] Looking for a device with Android '10'
[ADB] Setting device id to VBJDU18522004463
[ADB] Getting device platform version
[ADB] Running 'D:\android_sdk_test\android_sdk_test\platform-tools\adb.exe -P 5037 -s VBJDU18522004463 shell getprop ro.build.version.release'
[ADB] Current device property 'ro.build.version.release': 10
[AndroidDriver] Using device: VBJDU18522004463
[ADB] Using 'adb.exe' from 'D:\android_sdk_test\android_sdk_test\platform-tools\adb.exe'
[ADB] Setting device id to VBJDU18522004463
[ADB] Running 'D:\android_sdk_test\android_sdk_test\platform-tools\adb.exe -P 5037 -s VBJDU18522004463 shell getprop ro.build.version.sdk'
[ADB] Current device property 'ro.build.version.sdk': 29
[ADB] Device API level: 29
[UiAutomator2] Relaxing hidden api policy
[ADB] Running 'D:\android_sdk_test\android_sdk_test\platform-tools\adb.exe -P 5037 -s VBJDU18522004463 shell settings put global hidden_api_policy_pre_p_apps 1'
[ADB] Running 'D:\android_sdk_test\android_sdk_test\platform-tools\adb.exe -P 5037 -s VBJDU18522004463 shell settings put global hidden_api_policy_p_apps 1'
[ADB] Running 'D:\android_sdk_test\android_sdk_test\platform-tools\adb.exe -P 5037 -s VBJDU18522004463 shell settings put global hidden_api_policy 1'
[AndroidDriver] No app sent in, not parsing package/activity
[ADB] Running 'D:\android_sdk_test\android_sdk_test\platform-tools\adb.exe -P 5037 -s VBJDU18522004463 wait-for-device'
[ADB] Running 'D:\android_sdk_test\android_sdk_test\platform-tools\adb.exe -P 5037 -s VBJDU18522004463 shell echo ping'
[AndroidDriver] Pushing settings apk to device...
[ADB] Getting install status for io.appium.settings
[ADB] Running 'D:\android_sdk_test\android_sdk_test\platform-tools\adb.exe -P 5037 -s VBJDU18522004463 shell dumpsys package io.appium.settings'
[ADB] 'io.appium.settings' is installed
[ADB] Getting package info for 'io.appium.settings'
[ADB] Running 'D:\android_sdk_test\android_sdk_test\platform-tools\adb.exe -P 5037 -s VBJDU18522004463 shell dumpsys package io.appium.settings'
[ADB] Cannot extract apk info using apkanalyzer. Falling back to aapt. Original error: Could not find 'apkanalyzer.bat' in ["D:\\android_sdk_test\\android_sdk_test\\platform-tools\\apkanalyzer.bat","D:\\android_sdk_test\\android_sdk_test\\emulator\\apkanalyzer.bat","D:\\android_sdk_test\\android_sdk_test\\tools\\apkanalyzer.bat","D:\\android_sdk_test\\android_sdk_test\\tools\\bin\\apkanalyzer.bat","D:\\android_sdk_test\\android_sdk_test\\build-tools\\25.0.3\\apkanalyzer.bat"]. Do you have Android Build Tools installed at 'D:\android_sdk_test\android_sdk_test'?
[ADB] Using 'aapt.exe' from 'D:\android_sdk_test\android_sdk_test\build-tools\25.0.3\aapt.exe'
[ADB] The version name of the installed 'io.appium.settings' is greater or equal to the application version name ('2.14.2' >= '2.14.2')
[ADB] There is no need to install/upgrade 'C:\Program Files\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 'D:\android_sdk_test\android_sdk_test\platform-tools\adb.exe -P 5037 -s VBJDU18522004463 shell 'pgrep --help; echo $?''
[ADB] Running 'D:\android_sdk_test\android_sdk_test\platform-tools\adb.exe -P 5037 -s VBJDU18522004463 shell pgrep -f io\\.appium\\.settings'
[AndroidDriver] io.appium.settings is already running. There is no need to reset its permissions.
[ADB] Running 'D:\android_sdk_test\android_sdk_test\platform-tools\adb.exe -P 5037 -s VBJDU18522004463 shell appops set io.appium.settings android\:mock_location allow'
[Logcat] Starting logcat capture
[ADB] Getting install status for io.appium.uiautomator2.server
[ADB] Running 'D:\android_sdk_test\android_sdk_test\platform-tools\adb.exe -P 5037 -s VBJDU18522004463 shell dumpsys package io.appium.uiautomator2.server'
[ADB] 'io.appium.uiautomator2.server' is installed
[ADB] Getting package info for 'io.appium.uiautomator2.server'
[ADB] Running 'D:\android_sdk_test\android_sdk_test\platform-tools\adb.exe -P 5037 -s VBJDU18522004463 shell dumpsys package io.appium.uiautomator2.server'
[ADB] Cannot extract apk info using apkanalyzer. Falling back to aapt. Original error: Could not find 'apkanalyzer.bat' in ["D:\\android_sdk_test\\android_sdk_test\\platform-tools\\apkanalyzer.bat","D:\\android_sdk_test\\android_sdk_test\\emulator\\apkanalyzer.bat","D:\\android_sdk_test\\android_sdk_test\\tools\\apkanalyzer.bat","D:\\android_sdk_test\\android_sdk_test\\tools\\bin\\apkanalyzer.bat","D:\\android_sdk_test\\android_sdk_test\\build-tools\\25.0.3\\apkanalyzer.bat"]. Do you have Android Build Tools installed at 'D:\android_sdk_test\android_sdk_test'?
[ADB] The version name of the installed 'io.appium.uiautomator2.server' is greater or equal to the application version name ('4.3.0' >= '4.3.0')
[UiAutomator2] io.appium.uiautomator2.server installation state: sameVersionInstalled
[ADB] Checking app cert for C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-v4.3.0.apk
[ADB] Using 'apksigner.bat' from 'D:\android_sdk_test\android_sdk_test\build-tools\25.0.3\apksigner.bat'
[ADB] Starting 'D:\android_sdk_test\android_sdk_test\build-tools\25.0.3\apksigner.bat' with args '["verify","--print-certs","C:\\Program Files\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-uiautomator2-server\\apks\\appium-uiautomator2-server-v4.3.0.apk"]'
[ADB] apksigner stdout: Signer #1 certificate DN: EMAILADDRESS=android@android.com, CN=Android, OU=Android, O=Android, L=Mountain View, ST=California, C=US
[ADB] Signer #1 certificate SHA-256 digest: a40da80a59d170caa950cf15c18c454d47a39b26989d8b640ecd745ba71bf5dc
[ADB] Signer #1 certificate SHA-1 digest: 61ed377e85d386a8dfee6b864bd85b0bfaa5af81
[ADB] Signer #1 certificate MD5 digest: e89b158e4bcf988ebd09eb83f5378e87
[ADB] 
[ADB] 'C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-v4.3.0.apk' is already signed.
[ADB] Getting install status for io.appium.uiautomator2.server.test
[ADB] Running 'D:\android_sdk_test\android_sdk_test\platform-tools\adb.exe -P 5037 -s VBJDU18522004463 shell dumpsys package io.appium.uiautomator2.server.test'
[ADB] 'io.appium.uiautomator2.server.test' is installed
[ADB] Checking app cert for C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-debug-androidTest.apk
[ADB] Starting 'D:\android_sdk_test\android_sdk_test\build-tools\25.0.3\apksigner.bat' with args '["verify","--print-certs","C:\\Program Files\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-uiautomator2-server\\apks\\appium-uiautomator2-server-debug-androidTest.apk"]'
[ADB] apksigner stdout: Signer #1 certificate DN: EMAILADDRESS=android@android.com, CN=Android, OU=Android, O=Android, L=Mountain View, ST=California, C=US
[ADB] Signer #1 certificate SHA-256 digest: a40da80a59d170caa950cf15c18c454d47a39b26989d8b640ecd745ba71bf5dc
[ADB] Signer #1 certificate SHA-1 digest: 61ed377e85d386a8dfee6b864bd85b0bfaa5af81
[ADB] Signer #1 certificate MD5 digest: e89b158e4bcf988ebd09eb83f5378e87
[ADB] 
[ADB] 'C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-debug-androidTest.apk' is already signed.
[UiAutomator2] Server packages are not going to be (re)installed
[UiAutomator2] Waiting up to 30000ms for services to be available
[ADB] Running 'D:\android_sdk_test\android_sdk_test\platform-tools\adb.exe -P 5037 -s VBJDU18522004463 shell pm list instrumentation'
[UiAutomator2] Instrumentation target 'io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner' is available
[UiAutomator2] Forwarding UiAutomator2 Server port 6790 to 8200
[ADB] Forwarding system: 8200 to device: 6790
[ADB] Running 'D:\android_sdk_test\android_sdk_test\platform-tools\adb.exe -P 5037 -s VBJDU18522004463 forward tcp\:8200 tcp\:6790'
[UiAutomator2] No app capability. Assuming it is already on the device
[UiAutomator2] Performing shallow cleanup of automation leftovers
[UiAutomator2] No obsolete sessions have been detected (Error: socket hang up)
[ADB] Running 'D:\android_sdk_test\android_sdk_test\platform-tools\adb.exe -P 5037 -s VBJDU18522004463 shell am force-stop io.appium.uiautomator2.server.test'
[UiAutomator2] Starting UIAutomator2 server 4.3.0
[UiAutomator2] Using UIAutomator2 server from 'C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-v4.3.0.apk' and test from 'C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-debug-androidTest.apk'
[UiAutomator2] Waiting up to 30000ms for UiAutomator2 to be online...
[ADB] Creating ADB subprocess with args: ["-P",5037,"-s","VBJDU18522004463","shell","am","instrument","-w","io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner"]
[WD Proxy] Matched '/status' to command name 'getStatus'
[WD Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body
[WD Proxy] Got an unexpected response with status undefined: {"code":"ECONNRESET"}
[Instrumentation] io.appium.uiautomator2.server.test.AppiumUiAutomator2Server:
[WD Proxy] Matched '/status' to command name 'getStatus'
[WD Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body
[WD Proxy] Got an unexpected response with status undefined: {"code":"ECONNRESET"}
[WD Proxy] Matched '/status' to command name 'getStatus'
[WD Proxy] Proxying [GET /status] to [GET http://localhost:8200/wd/hub/status] with no body
[WD Proxy] Got response with status 200: {"sessionId":"None","value":{"ready":true,"message":"UiAutomator2 Server is ready to accept commands"}}
[UiAutomator2] The initialization of the instrumentation process took 3121ms
[WD Proxy] Matched '/session' to command name 'createSession'
[WD Proxy] Proxying [POST /session] to [POST http://localhost:8200/wd/hub/session] with body: {"capabilities":{"firstMatch":[{"platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"platformName":"Android","platformVersion":"10","deviceName":"VBJDU18522004463","noReset":true,"appPackage":"com.netease.newsreader.activity","appActivity":"com.netease.nr.phone.main.MainActivity"},"platformName":"Android","platformVersion":"10","deviceName":"VBJDU18522004463","noReset":true,"appPackage":"com.netease.newsreader.activity","appActivity":"com.netease.nr.phone.main.MainActivity","deviceUDID":"VBJDU18522004463"}],"alwaysMatch":{}}}
[WD Proxy] Got response with status 200: {"sessionId":"c48f60b6-1bc3-47f0-90bd-a2868d64f4ab","value":{"sessionId":"c48f60b6-1bc3-47f0-90bd-a2868d64f4ab","capabilities":{"firstMatch":[{"platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"platformName":"Android","platformVersion":"10","deviceName":"VBJDU18522004463","noReset":true,"appPackage":"com.netease.newsreader.activity","appActivity":"com.netease.nr.phone.main.MainActivity"},"platformName":"Android","platformVersion":"10","deviceName":"VBJDU18522004463","noReset":true,"appPackage":"com.netease.newsreader.activity","appActivity":"com.netease.nr.phone.main.MainActivity","deviceUDID":"VBJDU18522004463"}],"alwaysMatch":{}}}}
[WD Proxy] Determined the downstream protocol as 'W3C'
[WD Proxy] Proxying [GET /appium/device/info] to [GET http://localhost:8200/wd/hub/session/c48f60b6-1bc3-47f0-90bd-a2868d64f4ab/appium/device/info] with no body
[WD Proxy] Got response with status 200: {"sessionId":"c48f60b6-1bc3-47f0-90bd-a2868d64f4ab","value":{"androidId":"b6e8e08e13e7d453","manufacturer":"HUAWEI","model":"COL-AL10","brand":"HONOR","apiVersion":"29","platformVersion":"10","carrierName":"中国电信","realDisplaySize":"1080x2280","displayDensity":480,"networks":[{"type":1,"typeName":"WIFI","subtype":0,"subtypeName":"","isConnected":true,"detailedState":"CONNECTED","state":"CONNECTED","extraInfo":null,"isAvailable":true,"isFailover":false,"isRoaming":false,"capabilities":{"transportTypes":"NET_CAPABILITY_SUPL","networkCapabilities":"","linkUpstreamBandwidthKbps":1048576,"linkDownBandwidthKbps":1048576,"signalStrength":-65,"networkSpecifier":null,"SSID":null}}],"locale":"zh_CN_#Hans","timeZone":"Asia\/Shanghai"}}
[ADB] Running 'D:\android_sdk_test\android_sdk_test\platform-tools\adb.exe -P 5037 -s VBJDU18522004463 shell dumpsys window'
[AndroidDriver] Screen already unlocked, doing nothing
[UiAutomator2] Starting 'com.netease.newsreader.activity/com.netease.nr.phone.main.MainActivity and waiting for 'com.netease.newsreader.activity/com.netease.nr.phone.main.MainActivity'
[ADB] Running 'D:\android_sdk_test\android_sdk_test\platform-tools\adb.exe -P 5037 -s VBJDU18522004463 shell am start -W -n com.netease.newsreader.activity/com.netease.nr.phone.main.MainActivity -S'
[UiAutomator2] Deleting UiAutomator2 session
[UiAutomator2] Deleting UiAutomator2 server session
[WD Proxy] Matched '/' to command name 'deleteSession'
[WD Proxy] Proxying [DELETE /] to [DELETE http://localhost:8200/wd/hub/session/c48f60b6-1bc3-47f0-90bd-a2868d64f4ab] with no body
[WD Proxy] Got response with status 200: {"sessionId":"c48f60b6-1bc3-47f0-90bd-a2868d64f4ab","value":null}
[ADB] Running 'D:\android_sdk_test\android_sdk_test\platform-tools\adb.exe -P 5037 -s VBJDU18522004463 shell am force-stop com.netease.newsreader.activity'
[Logcat] Stopping logcat capture
[ADB] Removing forwarded port socket connection: 8200 
[ADB] Running 'D:\android_sdk_test\android_sdk_test\platform-tools\adb.exe -P 5037 -s VBJDU18522004463 forward --remove tcp\:8200'
[UiAutomator2] Restoring hidden api policy to the device default configuration
[ADB] Running 'D:\android_sdk_test\android_sdk_test\platform-tools\adb.exe -P 5037 -s VBJDU18522004463 shell settings delete global hidden_api_policy_pre_p_apps'
[Instrumentation] .
[ADB] Running 'D:\android_sdk_test\android_sdk_test\platform-tools\adb.exe -P 5037 -s VBJDU18522004463 shell settings delete global hidden_api_policy_p_apps'
[ADB] Running 'D:\android_sdk_test\android_sdk_test\platform-tools\adb.exe -P 5037 -s VBJDU18522004463 shell settings delete global hidden_api_policy'
[Instrumentation] Time: 3.044
[Instrumentation] 
[Instrumentation] OK (1 test)
[BaseDriver] Event 'newSessionStarted' logged at 1656954004170 (01:00:04 GMT+0800 (中国标准时间))
[W3C] Encountered internal error running command: Error: Cannot start the 'com.netease.newsreader.activity' 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:\\android_sdk_test\\android_sdk_test\\platform-tools\\adb.exe -P 5037 -s VBJDU18522004463 shell am start -W -n com.netease.newsreader.activity/com.netease.nr.phone.main.MainActivity -S' exited with code 255'; Stderr: 'Security exception: Permission Denial: starting Intent { flg=0x10000000 cmp=com.netease.newsreader.activity/com.netease.nr.phone.main.MainActivity } from null (pid=11412, uid=2000) not exported from uid 10234
[W3C] 
[W3C] java.lang.SecurityException: Permission Denial: starting Intent { flg=0x10000000 cmp=com.netease.newsreader.activity/com.netease.nr.phone.main.MainActivity } from null (pid=11412, uid=2000) not exported from uid 10234
[W3C]   at com.android.server.wm.ActivityStackSupervisor.checkStartAnyActivityPermission(libmapleservices.so:5245700)
[W3C]   at com.android.server.wm.ActivityStarter.startActivity(libmapleservices.so:5257824)
[W3C]   at com.android.server.wm.ActivityStarter.startActivity(libmapleservices.so:5281308)
[W3C]   at com.android.server.wm.HwActivityStarter.startActivity(libmaplehwServices.so:2037320)
[W3C]   at com.android.server.wm.ActivityStarter.startActivityMayWait(libmapleservices.so:5615824)
[W3C]   at com.android.server.wm.HwActivityStarter.startActivityMayWait(libmaplehwServices.so:2149344)
[W3C]   at com.android.server.wm.ActivityStarter.execute(libmapleservices.so:5247412)
[W3C]   at com.android.server.wm.ActivityTaskManagerService.startActivityAndWait(libmapleservices.so:8178916)
[W3C]   at com.android.server.am.ActivityManagerService.startActivityAndWait(libmapleservices.so:8179708)
[W3C]   at com.android.server.am.ActivityManagerShellCommand.runStartActivity(libmapleservices.so:8183652)
[W3C]   at com.android.server.am.ActivityManagerShellCommand.onCommand(libmapleservices.so:8195232)
[W3C]   at android.os.ShellCommand.exec(libmapleframework.so:2618468)
[W3C]   at com.android.server.am.ActivityManagerService.onShellCommand(libmapleservices.so:8196124)
[W3C]   at android.os.Binder.onTransact(libmapleframework.so:3613760)
[W3C]   at android.app.IActivityManager$Stub.onTransact(libmapleframework.so:6137408)
[W3C]   at com.android.server.am.ActivityManagerService.onTransact(libmapleservices.so:7783640)
[W3C]   at com.android.server.am.HwActivityManagerService.onTransact(libmaplehwServices.so:2475508)
[W3C]   at android.os.Binder.execTransactInternal(libmapleframework.so:6255628)
[W3C]   at android.os.Binder.execTransact(libmapleframework.so:6257424)'; Code: '255'
[W3C]     at ADB.startApp (C:\Program Files\Appium\resources\app\node_modules\appium\node_modules\appium-adb\lib\tools\apk-utils.js:153:11)
[HTTP] <-- POST /wd/hub/session 500 12502 ms - 5958
[HTTP] 
[Instrumentation] The process has exited with code 0

大佬帮忙看下!!!

最佳回复

adb shell dumpsys window | findstr mCurrentFocus 命令获取的是当前活动页的 Activity, 这个活动页不是你 app 的启动页,使用 appium 启动 app,需要的是 app 启动页的 Activity

获取 app 启动 activity 的办法
http://t.zoukankan.com/guo2733-p-10554633.html

共收到 8 条回复 时间 点赞

adb shell dumpsys window | findstr mCurrentFocus 命令获取的是当前活动页的 Activity, 这个活动页不是你 app 的启动页,使用 appium 启动 app,需要的是 app 启动页的 Activity

获取 app 启动 activity 的办法
http://t.zoukankan.com/guo2733-p-10554633.html

这个报错是指不允许直接拉起 MainActivity,应该是设置了 android:exported="false"。
先用 adb shell pm clear 包名
然后打开 app 后什么都别动再获取当前 activity。

https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/activity-startup.md 里面有相关报错的解决方案呢。如果你已经试了当我没说😂

前面几个回答已经说的很清楚,通俗点说就是有些 app 不允许通过包名加 activity 名直接调起 app 内的某个页面,必须先通过启动页面才行

在 AnroidManifest 文件中给 activity 节点设置 Android:exported="true",该属性表示当前 activity 能否被另外一个 Application 的组件启动,true 允许启动,false 不允许。默认是 false。注意:该属性是四大组件都拥有的。

所以,

  1. 别费劲了,不要设置启动 activity 就好了,
  2. 或者你找开发给你打开 true,给你出个测试包专门测试!
Diky #6 · 2022年07月05日 Author
Tester_谜城 回复

感谢大佬

Diky #7 · 2022年07月05日 Author
哲豪 回复

是的,没错,需要先获取启动页的 activity

Diky #8 · 2022年07月05日 Author
牧沐来了 回复

懂了,谢谢大佬

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册