I'm trying to establish a connection (session) between my Flutter App and Appium server but the Appium Flutter Driver always tries to listen on a different port from the correct port that is shown in the Flutter logs when I start the app, so the session fails!
A session between appium server and my app get established properly and the tests get executed.
All the tests fails since the session is not not established properly. The appium server tries to listen on a different port than the Dart VM Service works on (check the logs below).
appium -p 4723 --allow-insecure chromedriver_autodownload
[Appium] Welcome to Appium v2.19.0 (REV c19f08b3e8ea46ba94bd9315c46c0dda10ead31c)
[Appium] Non-default server args:
[Appium] {
allowInsecure: [
'chromedriver_autodownload'
]
}
[Appium] Explicitly enabling insecure features:
[Appium] *:chromedriver_autodownload
[Appium] The autodetected Appium home path: /Users/mazeed/.appium
[Appium] Attempting to load driver uiautomator2...
[Appium] Attempting to load driver xcuitest...
[Appium] Attempting to load driver flutter...
[Appium] Requiring driver at /Users/mazeed/.appium/node_modules/appium-uiautomator2-driver/build/index.js
[Appium] Requiring driver at /Users/mazeed/.appium/node_modules/appium-flutter-driver/build/lib/driver.js
[Appium] Requiring driver at /Users/mazeed/.appium/node_modules/appium-xcuitest-driver/build/index.js
[Appium] AndroidUiautomator2Driver has been successfully loaded in 0.448s
[Appium] XCUITestDriver has been successfully loaded in 0.954s
[Appium] FlutterDriver has been successfully loaded in 2.306s
[Appium] Appium REST http interface listener started on http://0.0.0.0:4723
[Appium] You can provide the following URLs in your client code to connect to this server:
http://127.0.0.1:4723/ (only accessible from the same host)
http://10.0.0.192:4723/
http://15.15.15.229:4723/
[Appium] Available drivers:
[Appium] - uiautomator2@4.2.4 (automationName 'UiAutomator2')
[Appium] - xcuitest@9.9.1 (automationName 'XCUITest')
[Appium] - flutter@2.18.1 (automationName 'Flutter')
[Appium] No plugins have been installed. Use the "appium plugin" command to install the one(s) you want to use.
[HTTP] Request idempotency key: c847d767-b751-4af9-b04d-ba6656b72349
[HTTP] --> POST /session {"capabilities":{"firstMatch":[{}],"alwaysMatch":{"appium:automationName":"Flutter","platformName":"Android","appium:deviceName":"emulator-5554","appium:appPackage":"com.example.appium_testing_poc","appium:appActivity":".MainActivity","appium:noReset":true,"appium:flutterServiceUrl":"ws://127.0.0.1:57429/ws"}}}
[AppiumDriver@b5d6] Calling AppiumDriver.createSession() with args: [null,null,{"firstMatch":[{}],"alwaysMatch":{"appium:automationName":"Flutter","platformName":"Android","appium:deviceName":"emulator-5554","appium:appPackage":"com.example.appium_testing_poc","appium:appActivity":".MainActivity","appium:noReset":true,"appium:flutterServiceUrl":"ws://127.0.0.1:57429/ws"}}]
[AppiumDriver@b5d6] Event 'newSessionRequested' logged at 1751809761236 (16:49:21 GMT+0300 (Eastern European Summer Time))
[Appium] Attempting to find matching driver for automationName 'Flutter' and platformName 'Android'
[Appium] The 'flutter' driver was installed and matched caps.
[Appium] Will require it at /Users/mazeed/.appium/node_modules/appium-flutter-driver
[Appium] Requiring driver at /Users/mazeed/.appium/node_modules/appium-flutter-driver/build/lib/driver.js
[AppiumDriver@b5d6] Appium v2.19.0 creating new FlutterDriver (v2.18.1) session
[AppiumDriver@b5d6] Checking BaseDriver versions for Appium and FlutterDriver
[AppiumDriver@b5d6] Appium's BaseDriver version is 9.18.0
[AppiumDriver@b5d6] FlutterDriver's BaseDriver version is 9.18.0
[AppiumDriver@b5d6] Explicitly enabling insecure features for this session as per the server configuration:
[AppiumDriver@b5d6] *:chromedriver_autodownload
[FlutterDriver@3250]
[FlutterDriver@3250] Creating session with W3C capabilities: {
"alwaysMatch": {
"platformName": "Android",
"appium:automationName": "Flutter",
"appium:deviceName": "emulator-5554",
"appium:appPackage": "com.example.appium_testing_poc",
"appium:appActivity": ".MainActivity",
"appium:noReset": true,
"appium:flutterServiceUrl": "ws://127.0.0.1:57429/ws"
},
"firstMatch": [
{}
]
}
[FlutterDriver@3250] The following provided capabilities were not recognized by this driver:
[FlutterDriver@3250] deviceName
[FlutterDriver@3250] appPackage
[FlutterDriver@3250] appActivity
[FlutterDriver@3250] flutterServiceUrl
[229c51f5][FlutterDriver@3250] Session created with session id: 229c51f5-4171-4031-b17b-a1527c0ee64f
[229c51f5][FlutterDriver@3250] Starting an Android proxy session
[229c51f5][AndroidUiautomator2Driver@e15b]
[229c51f5][AndroidUiautomator2Driver@e15b] Creating session with W3C capabilities: {
"alwaysMatch": {
"platformName": "Android",
"appium:automationName": "Flutter",
"appium:deviceName": "emulator-5554",
"appium:appPackage": "com.example.appium_testing_poc",
"appium:appActivity": ".MainActivity",
"appium:noReset": true,
"appium:flutterServiceUrl": "ws://127.0.0.1:57429/ws"
},
"firstMatch": [
{}
]
}
[229c51f5][AndroidUiautomator2Driver@e15b] The following provided capabilities were not recognized by this driver:
[229c51f5][AndroidUiautomator2Driver@e15b] flutterServiceUrl
[9c7a8bc9][AndroidUiautomator2Driver@e15b] Session created with session id: 9c7a8bc9-5ce1-49f1-addc-b8f69abb46dd
[9c7a8bc9][ADB] Found 3 'build-tools' folders under '/Users/mazeed/Library/Android/sdk' (newest first):
[9c7a8bc9][ADB] /Users/mazeed/Library/Android/sdk/build-tools/36.0.0
[9c7a8bc9][ADB] /Users/mazeed/Library/Android/sdk/build-tools/34.0.0
[9c7a8bc9][ADB] /Users/mazeed/Library/Android/sdk/build-tools/33.0.1
[9c7a8bc9][ADB] Using 'adb' from '/Users/mazeed/Library/Android/sdk/platform-tools/adb'
[9c7a8bc9][ADB] Running '/Users/mazeed/Library/Android/sdk/platform-tools/adb -P 5037 start-server'
[9c7a8bc9][AndroidUiautomator2Driver@e15b] Retrieving device list
[9c7a8bc9][ADB] Trying to find connected Android devices
[9c7a8bc9][ADB] Getting connected devices
[9c7a8bc9][ADB] Connected devices: [{"udid":"emulator-5554","state":"device"}]
[9c7a8bc9][AndroidUiautomator2Driver@e15b] Using device: emulator-5554
[9c7a8bc9][ADB] Using 'adb' from '/Users/mazeed/Library/Android/sdk/platform-tools/adb'
[9c7a8bc9][ADB] Running '/Users/mazeed/Library/Android/sdk/platform-tools/adb -P 5037 start-server'
[9c7a8bc9][ADB] Setting device id to emulator-5554
[9c7a8bc9][AndroidUiautomator2Driver@e15b] Starting 'com.example.appium_testing_poc' directly on the device
[9c7a8bc9][ADB] Running '/Users/mazeed/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell getprop ro.build.version.sdk'
[9c7a8bc9][ADB] Current device property 'ro.build.version.sdk': 34
[9c7a8bc9][ADB] Getting device platform version
[9c7a8bc9][ADB] Running '/Users/mazeed/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell getprop ro.build.version.release'
[9c7a8bc9][ADB] Current device property 'ro.build.version.release': 14
[9c7a8bc9][ADB] Device API level: 34
[9c7a8bc9][AndroidUiautomator2Driver@e15b] Relaxing hidden api policy
[9c7a8bc9][ADB] Running '/Users/mazeed/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell 'settings put global hidden_api_policy_pre_p_apps 1;settings put global hidden_api_policy_p_apps 1;settings put global hidden_api_policy 1''
[9c7a8bc9][ADB] Running '/Users/mazeed/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 wait-for-device'
[9c7a8bc9][ADB] Running '/Users/mazeed/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell echo ping'
[9c7a8bc9][AndroidUiautomator2Driver@e15b] Pushing settings apk to the device...
[9c7a8bc9][ADB] Getting package info for 'io.appium.settings'
[9c7a8bc9][ADB] Running '/Users/mazeed/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys package io.appium.settings'
[9c7a8bc9][ADB] App '/Users/mazeed/.appium/node_modules/appium-flutter-driver/node_modules/appium-uiautomator2-driver/node_modules/io.appium.settings/apks/settings_apk-debug.apk' is not installed
[9c7a8bc9][ADB] Installing '/Users/mazeed/.appium/node_modules/appium-flutter-driver/node_modules/appium-uiautomator2-driver/node_modules/io.appium.settings/apks/settings_apk-debug.apk'
[9c7a8bc9][ADB] Running '/Users/mazeed/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 help'
[9c7a8bc9][ADB] Running '/Users/mazeed/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 features'
[9c7a8bc9][ADB] The application at '/Users/mazeed/.appium/node_modules/appium-flutter-driver/node_modules/appium-uiautomator2-driver/node_modules/io.appium.settings/apks/settings_apk-debug.apk' will not be cached, because the device under test has confirmed the support of streamed installs
[9c7a8bc9][ADB] Running '/Users/mazeed/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 install -g /Users/mazeed/.appium/node_modules/appium-flutter-driver/node_modules/appium-uiautomator2-driver/node_modules/io.appium.settings/apks/settings_apk-debug.apk'
[9c7a8bc9][ADB] The installation of 'settings_apk-debug.apk' took 2759ms
[9c7a8bc9][ADB] Install command stdout: Performing Streamed Install
Success
[9c7a8bc9][ADB] Running '/Users/mazeed/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys activity services io.appium.settings'
[9c7a8bc9][ADB] Running '/Users/mazeed/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell cmd notification allow_listener io.appium.settings/.NLService'
[9c7a8bc9][ADB] Running '/Users/mazeed/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell appops set io.appium.settings PROJECT_MEDIA allow'
[9c7a8bc9][ADB] Running '/Users/mazeed/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys activity services io.appium.settings'
[9c7a8bc9][SettingsApp] Starting Appium Settings app
[9c7a8bc9][ADB] Running '/Users/mazeed/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell am start-activity -n io.appium.settings/.Settings -a android.intent.action.MAIN -c android.intent.category.LAUNCHER'
[9c7a8bc9][ADB] Running '/Users/mazeed/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys activity services io.appium.settings'
[9c7a8bc9][ADB] Running '/Users/mazeed/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys activity services io.appium.settings'
[9c7a8bc9][ADB] Running '/Users/mazeed/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys activity services io.appium.settings'
[9c7a8bc9][Logcat] Starting logs capture with command: /Users/mazeed/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 logcat -v threadtime
[9c7a8bc9][AndroidUiautomator2Driver@e15b] Forwarding UiAutomator2 Server port 6790 to local port 8200
[9c7a8bc9][ADB] Forwarding system: 8200 to device: 6790
[9c7a8bc9][ADB] Running '/Users/mazeed/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 forward tcp:8200 tcp:6790'
[9c7a8bc9][AndroidUiautomator2Driver@e15b] UIA2Proxy options: {"server":"127.0.0.1","port":8200,"keepAlive":true,"scheme":"http","base":"","reqBasePath":"","sessionId":null,"timeout":240000}
[9c7a8bc9][ADB] Getting package info for 'io.appium.uiautomator2.server'
[9c7a8bc9][ADB] Running '/Users/mazeed/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys package io.appium.uiautomator2.server'
[9c7a8bc9][ADB] Getting install status for io.appium.uiautomator2.server.test
[9c7a8bc9][AndroidUiautomator2Driver@e15b] No app capability. Assuming it is already on the device
[9c7a8bc9][ADB] Running '/Users/mazeed/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell cmd package list packages'
[9c7a8bc9][ADB] App '/Users/mazeed/.appium/node_modules/appium-flutter-driver/node_modules/appium-uiautomator2-driver/node_modules/appium-uiautomator2-server/apks/appium-uiautomator2-server-v7.6.2.apk' is not installed
[9c7a8bc9][ADB] 'io.appium.uiautomator2.server.test' is not installed
[9c7a8bc9][AndroidUiautomator2Driver@e15b] Server packages status: [{"installState":"notInstalled","appPath":"/Users/mazeed/.appium/node_modules/appium-flutter-driver/node_modules/appium-uiautomator2-driver/node_modules/appium-uiautomator2-server/apks/appium-uiautomator2-server-v7.6.2.apk","appId":"io.appium.uiautomator2.server"},{"installState":"notInstalled","appPath":"/Users/mazeed/.appium/node_modules/appium-flutter-driver/node_modules/appium-uiautomator2-driver/node_modules/appium-uiautomator2-server/apks/appium-uiautomator2-server-debug-androidTest.apk","appId":"io.appium.uiautomator2.server.test"}]
[9c7a8bc9][AndroidUiautomator2Driver@e15b] Server packages are going to be (re)installed
[9c7a8bc9][ADB] Running '/Users/mazeed/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 version'
[9c7a8bc9][ADB] The application at '/Users/mazeed/.appium/node_modules/appium-flutter-driver/node_modules/appium-uiautomator2-driver/node_modules/appium-uiautomator2-server/apks/appium-uiautomator2-server-v7.6.2.apk' will not be cached, because the device under test has confirmed the support of streamed installs
[9c7a8bc9][ADB] Running '/Users/mazeed/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 install -r --no-incremental /Users/mazeed/.appium/node_modules/appium-flutter-driver/node_modules/appium-uiautomator2-driver/node_modules/appium-uiautomator2-server/apks/appium-uiautomator2-server-v7.6.2.apk'
[9c7a8bc9][ADB] The application at '/Users/mazeed/.appium/node_modules/appium-flutter-driver/node_modules/appium-uiautomator2-driver/node_modules/appium-uiautomator2-server/apks/appium-uiautomator2-server-debug-androidTest.apk' will not be cached, because the device under test has confirmed the support of streamed installs
[9c7a8bc9][ADB] Running '/Users/mazeed/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 install -r --no-incremental /Users/mazeed/.appium/node_modules/appium-flutter-driver/node_modules/appium-uiautomator2-driver/node_modules/appium-uiautomator2-server/apks/appium-uiautomator2-server-debug-androidTest.apk'
[9c7a8bc9][FlutterDriver@3250] Matched the syslog line '07-06 16:48:34.900 5930 5984 I flutter : The Dart VM service is listening on http://127.0.0.1:35767/'
[9c7a8bc9][ADB] The installation of 'appium-uiautomator2-server-debug-androidTest.apk' took 406ms
[9c7a8bc9][ADB] Install command stdout: Performing Streamed Install
Success
[9c7a8bc9][ADB] The installation of 'appium-uiautomator2-server-v7.6.2.apk' took 493ms
[9c7a8bc9][ADB] Install command stdout: Performing Streamed Install
Success
[9c7a8bc9][AndroidUiautomator2Driver@e15b] Waiting up to 30000ms for services to be available
[9c7a8bc9][ADB] Running '/Users/mazeed/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell pm list instrumentation'
[9c7a8bc9][AndroidUiautomator2Driver@e15b] Instrumentation target 'io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner' is available
[9c7a8bc9][ADB] Adding packages ["io.appium.settings","io.appium.uiautomator2.server","io.appium.uiautomator2.server.test"] to Doze whitelist
[9c7a8bc9][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",";"]]
[9c7a8bc9][ADB] Running '/Users/mazeed/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys deviceidle whitelist +io.appium.settings ; dumpsys deviceidle whitelist +io.appium.uiautomator2.server ; dumpsys deviceidle whitelist +io.appium.uiautomator2.server.test ;'
[9c7a8bc9][AndroidUiautomator2Driver@e15b] Performing shallow cleanup of automation leftovers
[9c7a8bc9][AndroidUiautomator2Driver@e15b] No obsolete sessions have been detected (socket hang up)
[9c7a8bc9][ADB] Running '/Users/mazeed/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell am force-stop io.appium.uiautomator2.server'
[9c7a8bc9][ADB] Running '/Users/mazeed/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell am force-stop io.appium.uiautomator2.server.test'
[9c7a8bc9][AndroidUiautomator2Driver@e15b] Starting UIAutomator2 server 7.6.2
[9c7a8bc9][AndroidUiautomator2Driver@e15b] Using UIAutomator2 server from '/Users/mazeed/.appium/node_modules/appium-flutter-driver/node_modules/appium-uiautomator2-driver/node_modules/appium-uiautomator2-server/apks/appium-uiautomator2-server-v7.6.2.apk' and test from '/Users/mazeed/.appium/node_modules/appium-flutter-driver/node_modules/appium-uiautomator2-driver/node_modules/appium-uiautomator2-server/apks/appium-uiautomator2-server-debug-androidTest.apk'
[9c7a8bc9][AndroidUiautomator2Driver@e15b] Waiting up to 30000ms for UiAutomator2 to be online...
[9c7a8bc9][ADB] Creating ADB subprocess with args: ["-P","5037","-s","emulator-5554","shell","am","instrument","-w","-e","disableAnalytics","true","io.appium.uiautomator2.server.test/androidx.test.runner.AndroidJUnitRunner"]
[9c7a8bc9][AndroidUiautomator2Driver@e15b] Matched '/status' to command name 'getStatus'
[9c7a8bc9][AndroidUiautomator2Driver@e15b] Proxying [GET /status] to [GET http://127.0.0.1:8200/status] with no body
[9c7a8bc9][AndroidUiautomator2Driver@e15b] socket hang up
[9c7a8bc9][AndroidUiautomator2Driver@e15b] Matched '/status' to command name 'getStatus'
[9c7a8bc9][AndroidUiautomator2Driver@e15b] Proxying [GET /status] to [GET http://127.0.0.1:8200/status] with no body
[9c7a8bc9][AndroidUiautomator2Driver@e15b] socket hang up
[9c7a8bc9][AndroidUiautomator2Driver@e15b] [Instrumentation]
[9c7a8bc9][AndroidUiautomator2Driver@e15b] Matched '/status' to command name 'getStatus'
[9c7a8bc9][AndroidUiautomator2Driver@e15b] Proxying [GET /status] to [GET http://127.0.0.1:8200/status] with no body
[9c7a8bc9][AndroidUiautomator2Driver@e15b] Got response with status 200: {"sessionId":"None","value":{"build":{"version":"7.6.2","versionCode":218},"message":"UiAutomator2 Server is ready to accept commands","ready":true}}
[9c7a8bc9][AndroidUiautomator2Driver@e15b] The initialization of the instrumentation process took 2064ms
[9c7a8bc9][AndroidUiautomator2Driver@e15b] Matched '/session' to command name 'createSession'
[9c7a8bc9][AndroidUiautomator2Driver@e15b] Proxying [POST /session] to [POST http://127.0.0.1:8200/session] with body: {"capabilities":{"firstMatch":[{"platformName":"Android","automationName":"Flutter","deviceName":"emulator-5554","appPackage":"com.example.appium_testing_poc","appActivity":".MainActivity","noReset":true,"flutterServiceUrl":"ws://127.0.0.1:57429/ws","platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"platformName":"Android","automationName":"Flutter","deviceName":"emulator-5554","appPackage":"com.example.appium_testing_poc","appActivity":".MainActivity","noReset":true,"flutterServiceUrl":"ws://127.0.0.1:57429/ws"},"deviceUDID":"emulator-5554"}],"alwaysMatch":{}}}
[9c7a8bc9][AndroidUiautomator2Driver@e15b] Got response with status 200: {"sessionId":"774c9451-20cf-40b1-a8f6-5a76600bfe50","value":{"capabilities":{"firstMatch":[{"platformName":"Android","automationName":"Flutter","deviceName":"emulator-5554","appPackage":"com.example.appium_testing_poc","appActivity":".MainActivity","noReset":true,"flutterServiceUrl":"ws://127.0.0.1:57429/ws","platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"platformName":"Android","automationName":"Flutter","deviceName":"emulator-5554","appPackage":"com.example.appium_testing_poc","appActivity":".MainActivity","noReset":true,"flutterServiceUrl":"ws://127.0.0.1:57429/ws"},"deviceUDID":"emulator-5554"}],"alwaysMatch":{}},"sessionId":"774c9451-20cf-40b1-a8f6-5a76600bfe50"}}
[9c7a8bc9][AndroidUiautomator2Driver@e15b] Determined the downstream protocol as 'W3C'
[9c7a8bc9][AndroidUiautomator2Driver@e15b] Proxying [GET /appium/device/pixel_ratio] to [GET http://127.0.0.1:8200/session/774c9451-20cf-40b1-a8f6-5a76600bfe50/appium/device/pixel_ratio] with no body
[9c7a8bc9][AndroidUiautomator2Driver@e15b] Matched '/appium/device/system_bars' to command name 'getSystemBars'
[9c7a8bc9][AndroidUiautomator2Driver@e15b] Proxying [GET /appium/device/system_bars] to [GET http://127.0.0.1:8200/session/774c9451-20cf-40b1-a8f6-5a76600bfe50/appium/device/system_bars] with no body
[9c7a8bc9][AndroidUiautomator2Driver@e15b] Matched '/window/current/size' to command name 'getWindowSize'
[9c7a8bc9][AndroidUiautomator2Driver@e15b] Proxying [GET /window/current/size] to [GET http://127.0.0.1:8200/session/774c9451-20cf-40b1-a8f6-5a76600bfe50/window/current/size] with no body
[9c7a8bc9][AndroidUiautomator2Driver@e15b] Proxying [GET /appium/device/info] to [GET http://127.0.0.1:8200/session/774c9451-20cf-40b1-a8f6-5a76600bfe50/appium/device/info] with no body
[9c7a8bc9][ADB] Running '/Users/mazeed/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys window'
[9c7a8bc9][ADB] Running '/Users/mazeed/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys power'
[9c7a8bc9][AndroidUiautomator2Driver@e15b] Got response with status 200: {"sessionId":"774c9451-20cf-40b1-a8f6-5a76600bfe50","value":2.625}
[9c7a8bc9][AndroidUiautomator2Driver@e15b] Got response with status 200: {"sessionId":"774c9451-20cf-40b1-a8f6-5a76600bfe50","value":{"height":2400,"width":1080}}
[9c7a8bc9][AndroidUiautomator2Driver@e15b] Got response with status 200: {"sessionId":"774c9451-20cf-40b1-a8f6-5a76600bfe50","value":{"statusBar":63}}
[9c7a8bc9][AndroidUiautomator2Driver@e15b] Got response with status 200: {"sessionId":"774c9451-20cf-40b1-a8f6-5a76600bfe50","value":{"androidId":"dade77620e3d8a7a","apiVersion":"34","bluetooth":{"state":"ON"},"brand":"google","carrierName":"T-Mobile","displayDensity":420,"locale":"en_US","manufacturer":"Google","model":"sdk_gphone64_arm64","networks":[{"capabilities":{"SSID":null,"linkDownBandwidthKbps":4300,"linkUpstreamBandwidthKbps":1800,"networkCapabilities":"NET_CAPABILITY_MMS,NET_CAPABILITY_SUPL,NET_CAPABILITY_DUN,NET_CAPABILITY_FOTA,NET_CAPABILITY_IMS,NET_CAPABILITY_CBS,NET_CAPABILITY_INTERNET,NET_CAPABILITY_NOT_RESTRICTED,NET_CAPABILITY_TRUSTED,NET_CAPABILITY_NOT_VPN,NET_CAPABILITY_VALIDATED,NET_CAPABILITY_NOT_ROAMING,NET_CAPABILITY_FOREGROUND,NET_CAPABILITY_NOT_CONGESTED,NET_CAPABILITY_NOT_SUSPENDED","signalStrength":-2147483648,"transportTypes":"TRANSPORT_CELLULAR"},"detailedState":"CONNECTED","extraInfo":"epc.tmobile.com","isAvailable":true,"isConnected":true,"isFailover":false,"isRoaming":false,"state":"CONNECTED","subtype":13,"subtypeName":"LTE","type":0,"typeName...
[9c7a8bc9][AndroidUiautomator2Driver@e15b] Screen already unlocked, doing nothing
[9c7a8bc9][AndroidUiautomator2Driver@e15b] Starting 'com.example.appium_testing_poc/.MainActivity' and waiting for 'com.example.appium_testing_poc/.MainActivity'
[9c7a8bc9][ADB] Getting IDs of all 'com.example.appium_testing_poc' processes
[9c7a8bc9][ADB] Running '/Users/mazeed/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell 'pgrep --help; echo $?''
[9c7a8bc9][ADB] Running '/Users/mazeed/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell pgrep -f \(\[\[:blank:\]\]\|\^\)com\.example\.appium_testing_poc\(:\[a-zA-Z0-9_-\]\+\)\?\(\[\[:blank:\]\]\|\$\)'
[9c7a8bc9][AndroidUiautomator2Driver@e15b] 'com.example.appium_testing_poc' is already running and noReset is enabled. Set forceAppLaunch capability to true if the app must be forcefully restarted on session startup.
[9c7a8bc9][ADB] Forwarding system: 35767 to device: 35767
[9c7a8bc9][ADB] Running '/Users/mazeed/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 forward tcp:35767 tcp:35767'
[9c7a8bc9][FlutterDriver@3250] Establishing a connection to the Dart Observatory
[9c7a8bc9][FlutterDriver@3250] Connection to ws://127.0.0.1:35767/ws got an error: Unexpected server response: 302
[9c7a8bc9][FlutterDriver@3250] Deleting Flutter Driver session
[9c7a8bc9][FlutterDriver@3250] Cleanup the port forward
[9c7a8bc9][AppiumDriver@b5d6] Event 'newSessionStarted' logged at 1751809768561 (16:49:28 GMT+0300 (Eastern European Summer Time))
[9c7a8bc9][AppiumDriver@b5d6] Encountered internal error running command: Error: Cannot connect to the Dart Observatory URL ws://127.0.0.1:35767/ws. Check the server log for more details
at FlutterDriver.connectSocket (/Users/mazeed/.appium/node_modules/appium-flutter-driver/lib/sessions/observatory.ts:133:9)
at processTicksAndRejections (node:internal/process/task_queues:105:5)
at FlutterDriver.connectAndroidSession (/Users/mazeed/.appium/node_modules/appium-flutter-driver/lib/sessions/android.ts:49:10)
at FlutterDriver.startAndroidSession (/Users/mazeed/.appium/node_modules/appium-flutter-driver/lib/sessions/android.ts:38:5)
at FlutterDriver.createSession (/Users/mazeed/.appium/node_modules/appium-flutter-driver/lib/sessions/session.ts:47:43)
at AppiumDriver.createSession (/opt/homebrew/lib/node_modules/appium/lib/appium.js:379:35)
[9c7a8bc9][HTTP] <-- POST /session 500 7333 ms - 716
Description
I'm trying to establish a connection (session) between my Flutter App and Appium server but the Appium Flutter Driver always tries to listen on a different port from the correct port that is shown in the Flutter logs when I start the app, so the session fails!
Steps to Reproduce
1. Clean Slate (Kill All Old Processes):
Ensure no old processes are running that could interfere. Open a terminal and run:
killall -9 dart flutter node appium || true2. Start Emulator/Device
Make sure your Android emulator is running and unlocked. Verify it's connected with:
adb devices3. Start the Flutter App
In a new terminal, navigate to the project root and run the app with service auth codes disabled:
flutter run --debug --disable-service-auth-codes4. Find the Dart VM Service URL
Wait until the app launched and check the output logs the and find the Dart VM Service URL. It's like that...
A Dart VM Service on sdk gphone64 arm64 is available at: http://127.0.0.1:60693/Leave this terminal running.
5. Start the Appium Server
appiumThen wait until you see the log message [Appium] Appium REST http interface listener started on http://0.0.0.0:4723.
6. Activate Python Environment and Run Tests
In a final terminal, navigate to the project root, activate the virtual environment, and run the tests:
Expected Behavior
A session between appium server and my app get established properly and the tests get executed.
Actual Behavior
All the tests fails since the session is not not established properly. The appium server tries to listen on a different port than the Dart VM Service works on (check the logs below).
Screenshots / Logs
Flutter Logs
Appium Server Logs
Environment