0

I run the following code in my python But there is nothing happen on my android device. The appium don't launch any app on my android device. I have tried to use admin right to open appium desktop. And I also tried checked the " Allow Session Override" on appium but still don't work. I have also tried change the systemPort but still not work. My appium version is 1.22.0

from appium import webdriver

desired_cap = {
  "appium:deviceName": "BH9014465L",
  "platformName": "Android",
  "platformVersion": "8.0.0",
  "appPackage ": 'net.xnano.android.ftpserver',
  "appActivity": "net.xnano.android.ftpserver.MainActivity"
}


driver = webdriver.Remote("http://localhost:4723/wd/hub", desired_cap)

The appium log:

Matched '/' to command name 'deleteSession'
[WD Proxy] Proxying [DELETE /] to [DELETE http://127.0.0.1:8399/wd/hub/session/b000d8ff-aaaa-4c13-b249-d2b4bc7644fb] with no body
[WD Proxy] Got response with status 200: {"sessionId":"b000d8ff-aaaa-4c13-b249-d2b4bc7644fb","value":null}
[Logcat] Stopping logcat capture
[ADB] Removing forwarded port socket connection: 8399 
[ADB] Running 'D:\android-sdk\platform-tools\adb.exe -P 5037 -s BH9014465L forward --remove tcp:8399'
[Appium] Applying relaxed security to 'AndroidUiautomator2Driver' as per server command line argument. All insecure features will be enabled unless explicitly disabled by --deny-insecure
[BaseDriver] W3C capabilities and MJSONWP desired capabilities were provided
[BaseDriver] Creating session with W3C capabilities: {
[BaseDriver]   "alwaysMatch": {
[BaseDriver]     "platformName": "Android",
[BaseDriver]     "appium:deviceName": "BH9014465L",
[BaseDriver]     "appium:platformVersion": "8.0.0",
[BaseDriver]     "appium:appPackage ": "net.xnano.android.ftpserver",
[BaseDriver]     "appium:appActivity": "net.xnano.android.ftpserver.MainActivity"
[BaseDriver]   },
[BaseDriver]   "firstMatch": [
[BaseDriver]     {}
[BaseDriver]   ]
[BaseDriver] }
[BaseDriver] The following capabilities were provided, but are not recognized by Appium:
[BaseDriver]   appPackage 
[BaseDriver] Session created with session id: a6654c49-9424-48bf-a53d-bfc66dbd35c2
[UiAutomator2] Neither 'app' nor 'appPackage' was set. Starting UiAutomator2 without the target application
[ADB] Using 'adb.exe' from 'D:\android-sdk\platform-tools\adb.exe'
[ADB] Running 'D:\android-sdk\platform-tools\adb.exe -P 5037 start-server'
[AndroidDriver] Retrieving device list
[ADB] Trying to find a connected android device
[ADB] Getting connected devices
[ADB] Connected devices: [{"udid":"BH9014465L","state":"device"}]
[AndroidDriver] Looking for a device with Android '8.0.0'
[ADB] Setting device id to BH9014465L
[ADB] Getting device platform version
[ADB] Running 'D:\android-sdk\platform-tools\adb.exe -P 5037 -s BH9014465L shell getprop ro.build.version.release'
[ADB] Current device property 'ro.build.version.release': 8.0.0
[AndroidDriver] Using device: BH9014465L
[ADB] Using 'adb.exe' from 'D:\android-sdk\platform-tools\adb.exe'
[ADB] Running 'D:\android-sdk\platform-tools\adb.exe -P 5037 start-server'
[ADB] Setting device id to BH9014465L
[ADB] Running 'D:\android-sdk\platform-tools\adb.exe -P 5037 -s BH9014465L shell getprop ro.build.version.sdk'
[ADB] Current device property 'ro.build.version.sdk': 26
[ADB] Device API level: 26
[AndroidDriver] No app sent in, not parsing package/activity
[ADB] Running 'D:\android-sdk\platform-tools\adb.exe -P 5037 -s BH9014465L wait-for-device'
[ADB] Running 'D:\android-sdk\platform-tools\adb.exe -P 5037 -s BH9014465L shell echo ping'
[AndroidDriver] Pushing settings apk to device...
[ADB] Getting install status for io.appium.settings
[ADB] Running 'D:\android-sdk\platform-tools\adb.exe -P 5037 -s BH9014465L 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\platform-tools\adb.exe -P 5037 -s BH9014465L 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.4.0' >= '3.4.0')
[ADB] There is no need to install/upgrade 'C:\Program Files\Appium Server GUI\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\platform-tools\adb.exe -P 5037 -s BH9014465L shell 'pgrep --help; echo $?''
[Instrumentation] .
[ADB] Running 'D:\android-sdk\platform-tools\adb.exe -P 5037 -s BH9014465L shell 'pgrep ^appium\\.settings$ || pgrep ^io\\.appium\\.setti$''
[Instrumentation] Time: 432.589
[Instrumentation] 
[Instrumentation] OK (1 test)
[Instrumentation] The process has exited with code 0
[AndroidDriver] io.appium.settings is already running. There is no need to reset its permissions.
[ADB] Running 'D:\android-sdk\platform-tools\adb.exe -P 5037 -s BH9014465L shell appops set io.appium.settings android:mock_location allow'
[Logcat] Starting logs capture with command: D:\\android-sdk\\platform-tools\\adb.exe -P 5037 -s BH9014465L logcat -v threadtime
[UiAutomator2] Forwarding UiAutomator2 Server port 6790 to local port 8200
[ADB] Forwarding system: 8200 to device: 6790
[ADB] Running 'D:\android-sdk\platform-tools\adb.exe -P 5037 -s BH9014465L forward tcp:8200 tcp:6790'
[ADB] Getting install status for io.appium.uiautomator2.server
[ADB] Running 'D:\android-sdk\platform-tools\adb.exe -P 5037 -s BH9014465L 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\platform-tools\adb.exe -P 5037 -s BH9014465L shell dumpsys package io.appium.uiautomator2.server'
[ADB] The version name of the installed 'io.appium.uiautomator2.server' is greater or equal to the application version name ('4.24.0' >= '4.24.0')
[UiAutomator2] io.appium.uiautomator2.server installation state: sameVersionInstalled
[ADB] Checking app cert for C:\Program Files\Appium Server GUI\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-v4.24.0.apk
[ADB] Using the previously cached signature entry for 'appium-uiautomator2-server-v4.24.0.apk'
[ADB] sha256 hash did match for 'appium-uiautomator2-server-v4.24.0.apk'
[ADB] Getting install status for io.appium.uiautomator2.server.test
[ADB] Running 'D:\android-sdk\platform-tools\adb.exe -P 5037 -s BH9014465L 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 Server GUI\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-debug-androidTest.apk
[ADB] Using the previously cached signature entry for 'appium-uiautomator2-server-debug-androidTest.apk'
[ADB] sha256 hash did match for 'appium-uiautomator2-server-debug-androidTest.apk'
[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\platform-tools\adb.exe -P 5037 -s BH9014465L shell pm list instrumentation'
[UiAutomator2] Instrumentation target 'io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner' is available
[ADB] Adding packages ["io.appium.settings","io.appium.uiautomator2.server","io.appium.uiautomator2.server.test"] to Doze whitelist
[ADB] Got the following command chunks to execute: [["dumpsys","deviceidle","whitelist","+io.appium.settings",";","dumpsys","deviceidle","whitelist","+io.appium.uiautomator2.server",";","dumpsys","deviceidle","whitelist","+io.appium.uiautomator2.server.test",";"]]
[ADB] Running 'D:\android-sdk\platform-tools\adb.exe -P 5037 -s BH9014465L shell dumpsys deviceidle whitelist +io.appium.settings ; dumpsys deviceidle whitelist +io.appium.uiautomator2.server ; dumpsys deviceidle whitelist +io.appium.uiautomator2.server.test ;'
[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 (socket hang up)
[ADB] Running 'D:\android-sdk\platform-tools\adb.exe -P 5037 -s BH9014465L shell am force-stop io.appium.uiautomator2.server.test'
[UiAutomator2] Starting UIAutomator2 server 4.24.0
[UiAutomator2] Using UIAutomator2 server from 'C:\Program Files\Appium Server GUI\resources\app\node_modules\appium\node_modules\appium-uiautomator2-server\apks\appium-uiautomator2-server-v4.24.0.apk' and test from 'C:\Program Files\Appium Server GUI\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","BH9014465L","shell","am","instrument","-w","-e","disableAnalytics",true,"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://127.0.0.1:8200/wd/hub/status] with no body
[WD Proxy] socket hang up
[WD Proxy] Matched '/status' to command name 'getStatus'
[WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8200/wd/hub/status] with no body
[WD Proxy] socket hang up
[Instrumentation] io.appium.uiautomator2.server.test.AppiumUiAutomator2Server:
[WD Proxy] Matched '/status' to command name 'getStatus'
[WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8200/wd/hub/status] with no body
[WD Proxy] socket hang up
[WD Proxy] Matched '/status' to command name 'getStatus'
[WD Proxy] Proxying [GET /status] to [GET http://127.0.0.1:8200/wd/hub/status] with no body
[WD Proxy] Got response with status 200: {"sessionId":"None","value":{"message":"UiAutomator2 Server is ready to accept commands","ready":true}}
[UiAutomator2] The initialization of the instrumentation process took 3242ms
[WD Proxy] Matched '/session' to command name 'createSession'
[WD Proxy] Proxying [POST /session] to [POST http://127.0.0.1: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","deviceName":"BH9014465L","platformVersion":"8.0.0","appPackage ":"net.xnano.android.ftpserver","appActivity":"net.xnano.android.ftpserver.MainActivity"},"platformName":"Android","deviceName":"BH9014465L","platformVersion":"8.0.0","appPackage ":"net.xnano.android.ftpserver","appActivity":"net.xnano.android.ftpserver.MainActivity","deviceUDID":"BH9014465L"}],"alwaysMatch":{}}}
[WD Proxy] Got response with status 200: {"sessionId":"f068b515-077d-4b9e-9657-b382034ef8d4","value":{"capabilities":{"firstMatch":[{"platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"platformName":"Android","deviceName":"BH9014465L","platformVersion":"8.0.0","appPackage ":"net.xnano.android.ftpserver","appActivity":"net.xnano.android.ftpserver.MainActivity"},"platformName":"Android","deviceName":"BH9014465L","platformVersion":"8.0.0","appPackage ":"net.xnano.android.ftpserver","appActivity":"net.xnano.android.ftpserver.MainActivity","deviceUDID":"BH9014465L"}],"alwaysMatch":{}},"sessionId":"f068b515-077d-4b9e-9657-b382034ef8d4"}}
[WD Proxy] Determined the downstream protocol as 'W3C'
[WD Proxy] Proxying [GET /appium/device/info] to [GET http://127.0.0.1:8200/wd/hub/session/f068b515-077d-4b9e-9657-b382034ef8d4/appium/device/info] with no body
[WD Proxy] Got response with status 200: {"sessionId":"f068b515-077d-4b9e-9657-b382034ef8d4","value":{"androidId":"befd45229d2f8e0d","apiVersion":"26","bluetooth":{"state":"OFF"},"brand":"Sony","carrierName":"","displayDensity":480,"locale":"zh_HK","manufacturer":"Sony","model":"F5122","networks":[],"platformVersion":"8.0.0","realDisplaySize":"1080x1920","timeZone":"Asia/Hong_Kong"}}
[ADB] Running 'D:\android-sdk\platform-tools\adb.exe -P 5037 -s BH9014465L shell dumpsys window'
[AndroidDriver] Screen already unlocked, doing nothing
[WD Proxy] Proxying [GET /appium/device/pixel_ratio] to [GET http://127.0.0.1:8200/wd/hub/session/f068b515-077d-4b9e-9657-b382034ef8d4/appium/device/pixel_ratio] with no body
[WD Proxy] Got response with status 200: {"sessionId":"f068b515-077d-4b9e-9657-b382034ef8d4","value":3}
[WD Proxy] Matched '/appium/device/system_bars' to command name 'getSystemBars'
[WD Proxy] Proxying [GET /appium/device/system_bars] to [GET http://127.0.0.1:8200/wd/hub/session/f068b515-077d-4b9e-9657-b382034ef8d4/appium/device/system_bars] with no body
[WD Proxy] Got response with status 200: {"sessionId":"f068b515-077d-4b9e-9657-b382034ef8d4","value":{"statusBar":72}}
[WD Proxy] Matched '/window/current/size' to command name 'getWindowSize'
[WD Proxy] Proxying [GET /window/current/size] to [GET http://127.0.0.1:8200/wd/hub/session/f068b515-077d-4b9e-9657-b382034ef8d4/window/current/size] with no body
[WD Proxy] Got response with status 200: {"sessionId":"f068b515-077d-4b9e-9657-b382034ef8d4","value":{"height":1776,"width":1080}}
[Appium] New AndroidUiautomator2Driver session created successfully, session a6654c49-9424-48bf-a53d-bfc66dbd35c2 added to master session list
[BaseDriver] Event 'newSessionStarted' logged at 1634375217171 (17:06:57 GMT+0800 (中國標準時間))
[W3C (a6654c49)] Cached the protocol value 'W3C' for the new session a6654c49-9424-48bf-a53d-bfc66dbd35c2
[W3C (a6654c49)] Responding to client with driver.createSession() result: {"capabilities":{"platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"platformName":"Android","deviceName":"BH9014465L","platformVersion":"8.0.0","appPackage ":"net.xnano.android.ftpserver","appActivity":"net.xnano.android.ftpserver.MainActivity"},"platformName":"Android","deviceName":"BH9014465L","platformVersion":"8.0.0","appPackage ":"net.xnano.android.ftpserver","appActivity":"net.xnano.android.ftpserver.MainActivity","deviceUDID":"BH9014465L","deviceApiLevel":26,"deviceScreenSize":"1080x1920","deviceScreenDensity":480,"deviceModel":"F5122","deviceManufacturer":"Sony","pixelRatio":3,"statBarHeight":72,"viewportRect":{"left":0,"top":72,"width":1080,"height":1704}}}
[HTTP] <-- POST /wd/hub/session 200 7408 ms - 890
[HTTP] 
[BaseDriver] Shutting down because we waited 60 seconds for a command
[Appium] Closing session, cause was 'New Command Timeout of 60 seconds expired. Try customizing the timeout using the 'newCommandTimeout' desired capability'
[Appium] Removing session 'a6654c49-9424-48bf-a53d-bfc66dbd35c2' from our master session list
[UiAutomator2] Deleting UiAutomator2 session
[UiAutomator2] Deleting UiAutomator2 server session
[WD Proxy] Matched '/' to command name 'deleteSession'
[WD Proxy] Proxying [DELETE /] to [DELETE http://127.0.0.1:8200/wd/hub/session/f068b515-077d-4b9e-9657-b382034ef8d4] with no body
[WD Proxy] socket hang up
[UiAutomator2] Did not get confirmation UiAutomator2 deleteSession worked; Error was: UnknownError: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to the remote server. Original error: socket hang up
[Logcat] Stopping logcat capture
[ADB] Removing forwarded port socket connection: 8200 
[ADB] Running 'D:\android-sdk\platform-tools\adb.exe -P 5037 -s BH9014465L forward --remove tcp:8200'
jam
  • 1
  • 1

2 Answers2

0

I may be wrong but I am pretty sure that on appium python you can't use appPackage and appActivity, you have to use app and import a zip containing your app:
"app": "path/to/app.zip"
UPDATE: You can use .apk instead of .zip since they are technically the same.
Example: https://github.com/appium/python-client#usage

FurrySenko
  • 549
  • 3
  • 12
0

In the section Remote Path add : "/wd/hub"

Myriam
  • 25
  • 1
  • 6
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 29 '21 at 11:54