2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

XamarinAdvent Calendar 2019

Day 19

XamarinアプリをAppium連携する方法について(Android編)

Last updated at Posted at 2019-12-22

この記事は、Xamarin Advent Calendar 2019の19日目の記事です。

先日、Appiumの連携でiOSでハマった問題と解決方法をまとめた記事をアップしました。

今回は、XamarinアプリをAppium連携する際にXamarin.Androidで絶賛ハマっている内容を紹介しようと思います。

環境

  • MacBookPro Mojave 10.14
  • Appium 1.15.1
  • Visual Studio for Mac 8.3.7
    • Xamarin.Android 10.0.6.2
    • Xamarin.iOS 13.6.0.12

Appium連携

セットアップ

まず前提知識として、ネイティブのAndroidアプリをAppiumで実行する方法を理解している前提で話を進めていきます。

Xamarin.Androidの場合、Droid/Properties/AndroidManifest.xmlには、最低限の設定しか行わず、各Activityクラスにプロパティを設定する必要があり、もしNameプロパティがActivityクラスに設定が無い場合は、ビルドされたAndroidManifest.xmlandroid:nameタグにハッシュ付きのActivityクラス名が設定されます。

スクリーンショット 2019-12-22 16.44.50.png スクリーンショット 2019-12-22 16.25.00.png ちなみにビルドされた`AndroidManifest.xml`は、`Droid/obj/Debug/android/AndroidManifest.xml`にあるので、一度`プロジェクト名.Droid`をビルドする必要があります。 スクリーンショット 2019-12-22 16.26.18.png スクリーンショット 2019-12-22 16.39.02.png スクリーンショット 2019-12-22 16.40.00.png

詳細:Android マニフェストの操作

次に上記の情報を踏まえてAppium側と連携する設定を行なっていきます。設定の際に一度、実機/エミュレータにアプリをビルドしておく必要があります。

スクリーンショット 2019-12-22 16.28.07.png

.apkの場所ですが、Droid/bin/Debug/配下にビルドされています。

スクリーンショット 2019-12-22 16.27.53.png

問題

次の動画のようにアプリが異常動作し、Appiumは毎度アプリを入れ直すのでその後のアプリは壊れてしまします。

検証

次の検証を行なってみました。

  1. Activityクラス名にNameプロパティを付けてハッシュを無くす。
  2. 対象のAndroidバージョンをデバイスに合わせてポップアップを出さなくする。
  3. MainActivityをスプラッシュ画面ではなく、メイン画面に変更する。

結果としては、全く改善できませんでした笑汗

1は動画と同じ状況で2は動画後半のスプラッシュ画面でフリーズしてしまう状態でAppiumもローディングから抜け出せない状態になってしまします。
3は、メイン画面を開けるもののAppiumがローディングから抜け出せない状況が続き、最終的にはタイムアウトのエラーで異常終了してしまう結果となります。

Appiumのログを見てもタイムアウト以外のエラーは、Got an error during apksigner execution ...だけで、これが原因であれば署名をしていなかったネイティブのAndroidアプリでAppium連携できないはずだけども正常に連携できたので原因では無さそうで、、、打つ手無し状態です笑汗

[Appium] Welcome to Appium v1.15.1
[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 8 ms - 40
[HTTP] 
[HTTP] --> POST /wd/hub/session
[HTTP] {"desiredCapabilities":{"app":"/Users/gremito/Xamarin/AppiumTestForXamarin/Droid/bin/Debug/net.gremito.app.appiumtestforxamarin.apk","appActivity":"net.gremito.app.appiumtestforxamarin.MainActivity","appPackage":"net.gremito.app.appiumtestforxamarin","automationName":"UiAutomator2","deviceName":"Android Emulator","platformName":"Android","newCommandTimeout":0,"connectHardwareKeyboard":true}}
[MJSONWP] Calling AppiumDriver.createSession() with args: [{"app":"/Users/gremito/Xamarin/AppiumTestForXamarin/Droid/bin/Debug/net.gremito.app.appiumtestforxamarin.apk","appActivity":"net.gremito.app.appiumtestforxamarin.MainActivity","appPackage":"net.gremito.app.appiumtestforxamarin","automationName":"UiAutomator2","deviceName":"Android Emulator","platformName":"Android","newCommandTimeout":0,"connectHardwareKeyboard":true},null,null]
[BaseDriver] Event 'newSessionRequested' logged at 1577003532774 (17:32:12 GMT+0900 (JST))
[Appium] Appium v1.15.1 creating new AndroidUiautomator2Driver (v1.37.2) session
[BaseDriver] Creating session with MJSONWP desired capabilities: {
[BaseDriver]   "app": "/Users/gremito/Xamarin/AppiumTestForXamarin/Droid/bin/Debug/net.gremito.app.appiumtestforxamarin.apk",
[BaseDriver]   "appActivity": "net.gremito.app.appiumtestforxamarin.MainActivity",
[BaseDriver]   "appPackage": "net.gremito.app.appiumtestforxamarin",
[BaseDriver]   "automationName": "UiAutomator2",
[BaseDriver]   "deviceName": "Android Emulator",
[BaseDriver]   "platformName": "Android",
[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: 9a87fb97-0ded-404e-89c1-24158c5438b4
[BaseDriver] Using local app '/Users/gremito/Xamarin/AppiumTestForXamarin/Droid/bin/Debug/net.gremito.app.appiumtestforxamarin.apk'
[UiAutomator2] Checking whether app is actually present
[ADB] Found 6 'build-tools' folders under '/Users/gremito/Library/Android/sdk' (newest first):
[ADB]     /Users/gremito/Library/Android/sdk/build-tools/29.0.2
[ADB]     /Users/gremito/Library/Android/sdk/build-tools/29.0.1
[ADB]     /Users/gremito/Library/Android/sdk/build-tools/28.0.3
[ADB]     /Users/gremito/Library/Android/sdk/build-tools/28.0.2
[ADB]     /Users/gremito/Library/Android/sdk/build-tools/28.0.0
[ADB]     /Users/gremito/Library/Android/sdk/build-tools/27.0.3
[ADB] Using 'adb' from '/Users/gremito/Library/Android/sdk/platform-tools/adb'
[AndroidDriver] Retrieving device list
[ADB] Trying to find a connected android device
[ADB] Getting connected devices...
[ADB] Connected devices: [{"udid":"emulator-5554","state":"device"}]
[AndroidDriver] Using device: emulator-5554
[ADB] Using 'adb' from '/Users/gremito/Library/Android/sdk/platform-tools/adb'
[ADB] Setting device id to emulator-5554
[ADB] Running '/Users/gremito/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell getprop ro.build.version.sdk'
[ADB] Current device property 'ro.build.version.sdk': 28
[ADB] Running '/Users/gremito/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell getprop ro.build.version.release'
[ADB] Current device property 'ro.build.version.release': 9
[ADB] Device API level: 28
[UiAutomator2] Relaxing hidden api policy
[ADB] Running '/Users/gremito/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell settings put global hidden_api_policy_pre_p_apps 1'
[ADB] Running '/Users/gremito/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell settings put global hidden_api_policy_p_apps 1'
[ADB] Running '/Users/gremito/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell settings put global hidden_api_policy 1'
[ADB] Running '/Users/gremito/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 wait-for-device'
[ADB] Running '/Users/gremito/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell echo ping'
[AndroidDriver] Pushing settings apk to device...
[ADB] Getting install status for io.appium.settings
[ADB] Running '/Users/gremito/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys package io.appium.settings'
[ADB] 'io.appium.settings' is installed
[ADB] Getting package info for 'io.appium.settings'
[ADB] Running '/Users/gremito/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys package io.appium.settings'
[ADB] Using 'apkanalyzer' from '/Users/gremito/Library/Android/sdk/tools/bin/apkanalyzer'
[ADB] Starting '/Users/gremito/Library/Android/sdk/tools/bin/apkanalyzer' with args ["manifest","print","/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/io.appium.settings/apks/settings_apk-debug.apk"]
[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 '/Applications/Appium.app/Contents/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 '/Users/gremito/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell 'pgrep --help; echo $?''
[ADB] Running '/Users/gremito/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell pgrep -f io\\.appium\\.settings'
[AndroidDriver] io.appium.settings is already running. There is no need to reset its permissions.
[ADB] Running '/Users/gremito/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 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 '/Users/gremito/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 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 '/Users/gremito/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys package io.appium.uiautomator2.server'
[ADB] Starting '/Users/gremito/Library/Android/sdk/tools/bin/apkanalyzer' with args ["manifest","print","/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-uiautomator2-server/apks/appium-uiautomator2-server-v4.3.0.apk"]
[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 /Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-uiautomator2-server/apks/appium-uiautomator2-server-v4.3.0.apk
[ADB] Using 'apksigner' from '/Users/gremito/Library/Android/sdk/build-tools/29.0.2/apksigner'
[ADB] Starting '/Users/gremito/Library/Android/sdk/build-tools/29.0.2/apksigner' with args '["verify","--print-certs","/Applications/Appium.app/Contents/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] '/Applications/Appium.app/Contents/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 '/Users/gremito/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys package io.appium.uiautomator2.server.test'
[ADB] 'io.appium.uiautomator2.server.test' is installed
[ADB] Checking app cert for /Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-uiautomator2-server/apks/appium-uiautomator2-server-debug-androidTest.apk
[ADB] Starting '/Users/gremito/Library/Android/sdk/build-tools/29.0.2/apksigner' with args '["verify","--print-certs","/Applications/Appium.app/Contents/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] '/Applications/Appium.app/Contents/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 '/Users/gremito/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 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 '/Users/gremito/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 forward tcp\:8200 tcp\:6790'
[ADB] Checking app cert for /Users/gremito/Xamarin/AppiumTestForXamarin/Droid/bin/Debug/net.gremito.app.appiumtestforxamarin.apk
[ADB] Starting '/Users/gremito/Library/Android/sdk/build-tools/29.0.2/apksigner' with args '["verify","--print-certs","/Users/gremito/Xamarin/AppiumTestForXamarin/Droid/bin/Debug/net.gremito.app.appiumtestforxamarin.apk"]'
[ADB] Got an error during apksigner execution: Command '/Users/gremito/Library/Android/sdk/build-tools/29.0.2/apksigner verify --print-certs /Users/gremito/Xamarin/AppiumTestForXamarin/Droid/bin/Debug/net.gremito.app.appiumtestforxamarin.apk' exited with code 1
[ADB] apksigner stderr: DOES NOT VERIFY
[ADB] ERROR: Missing META-INF/MANIFEST.MF
[ADB] 
[ADB] '/Users/gremito/Xamarin/AppiumTestForXamarin/Droid/bin/Debug/net.gremito.app.appiumtestforxamarin.apk' is not signed with debug cert
[ADB] Using 'zipalign' from '/Users/gremito/Library/Android/sdk/build-tools/29.0.2/zipalign'
[ADB] '/Users/gremito/Xamarin/AppiumTestForXamarin/Droid/bin/Debug/net.gremito.app.appiumtestforxamarin.apk' is not zip-aligned. Aligning
[ADB] Signing '/Users/gremito/Xamarin/AppiumTestForXamarin/Droid/bin/Debug/net.gremito.app.appiumtestforxamarin.apk' with default cert
[ADB] Starting '/Users/gremito/Library/Android/sdk/build-tools/29.0.2/apksigner' with args '["sign","--key","/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-adb/keys/testkey.pk8","--cert","/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-adb/keys/testkey.x509.pem","/Users/gremito/Xamarin/AppiumTestForXamarin/Droid/bin/Debug/net.gremito.app.appiumtestforxamarin.apk"]'
[ADB] Getting install status for net.gremito.app.appiumtestforxamarin
[ADB] Running '/Users/gremito/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys package net.gremito.app.appiumtestforxamarin'
[ADB] 'net.gremito.app.appiumtestforxamarin' is installed
[ADB] Getting package info for 'net.gremito.app.appiumtestforxamarin'
[ADB] Running '/Users/gremito/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys package net.gremito.app.appiumtestforxamarin'
[ADB] Starting '/Users/gremito/Library/Android/sdk/tools/bin/apkanalyzer' with args ["manifest","print","/Users/gremito/Xamarin/AppiumTestForXamarin/Droid/bin/Debug/net.gremito.app.appiumtestforxamarin.apk"]
[ADB] The version name of the installed 'net.gremito.app.appiumtestforxamarin' is greater or equal to the application version name ('1.0.0' >= '1.0.0')
[ADB] There is no need to install/upgrade '/Users/gremito/Xamarin/AppiumTestForXamarin/Droid/bin/Debug/net.gremito.app.appiumtestforxamarin.apk'
[AndroidDriver] Performing fast reset on 'net.gremito.app.appiumtestforxamarin'
[ADB] Getting install status for net.gremito.app.appiumtestforxamarin
[ADB] Running '/Users/gremito/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys package net.gremito.app.appiumtestforxamarin'
[ADB] 'net.gremito.app.appiumtestforxamarin' is installed
[ADB] Running '/Users/gremito/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell am force-stop net.gremito.app.appiumtestforxamarin'
[ADB] Running '/Users/gremito/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell pm clear net.gremito.app.appiumtestforxamarin'
[AndroidDriver] Performed fast reset on the installed 'net.gremito.app.appiumtestforxamarin' application (stop and clear)
[UiAutomator2] Performing shallow cleanup of automation leftovers
[UiAutomator2] No obsolete sessions have been detected (Error: socket hang up)
[ADB] Running '/Users/gremito/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell am force-stop io.appium.uiautomator2.server.test'
[UiAutomator2] Starting UIAutomator2 server 4.3.0
[UiAutomator2] Using UIAutomator2 server from '/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-uiautomator2-server/apks/appium-uiautomator2-server-v4.3.0.apk' and test from '/Applications/Appium.app/Contents/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","emulator-5554","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 3277ms
[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":{"app":"/Users/gremito/Xamarin/AppiumTestForXamarin/Droid/bin/Debug/net.gremito.app.appiumtestforxamarin.apk","appActivity":"net.gremito.app.appiumtestforxamarin.MainActivity","appPackage":"net.gremito.app.appiumtestforxamarin","automationName":"UiAutomator2","deviceName":"Android Emulator","platformName":"Android","newCommandTimeout":0,"connectHardwareKeyboard":true},"app":"/Users/gremito/Xamarin/AppiumTestForXamarin/Droid/bin/Debug/net.gremito.app.appiumtestforxamarin.apk","appActivity":"net.gremito.app.appiumtestforxamarin.MainActivity","appPackage":"net.gremito.app.appiumtestforxamarin","automationName":"UiAutomator2","deviceName":"emulator-5554","platformName":"Android","newCommandTimeout":0,"connectHardwareKeyboard":true,"deviceUDID":"emulator-5554"}],"alwaysMatch":{}}}
[WD Proxy] Got response with status 200: {"sessionId":"6572217d-4279-4704-9475-7e2c95ba3153","value":{"sessionId":"6572217d-4279-4704-9475-7e2c95ba3153","capabilities":{"firstMatch":[{"platform":"LINUX","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"app":"/Users/gremito/Xamarin/AppiumTestForXamarin/Droid/bin/Debug/net.gremito.app.appiumtestforxamarin.apk","appActivity":"net.gremito.app.appiumtestforxamarin.MainActivity","appPackage":"net.gremito.app.appiumtestforxamarin","automationName":"UiAutomator2","deviceName":"Android Emulator","platformName":"Android","newCommandTimeout":0,"connectHardwareKeyboard":true},"app":"/Users/gremito/Xamarin/AppiumTestForXamarin/Droid/bin/Debug/net.gremito.app.appiumtestforxamarin.apk","appActivity":"net.gremito.app.appiumtestforxamarin.MainActivity","appPackage":"net.gremito.app.appiumtestforxamarin","automationName":"UiAutomator2","deviceName":"emulator-5554","platformName":...
[WD Proxy] Determined the downstream protocol as 'W3C'
[WD Proxy] Proxying [GET /appium/device/info] to [GET http://localhost:8200/wd/hub/session/6572217d-4279-4704-9475-7e2c95ba3153/appium/device/info] with no body
[WD Proxy] Got response with status 200: {"sessionId":"6572217d-4279-4704-9475-7e2c95ba3153","value":{"androidId":"f5a8d6d0364faa08","manufacturer":"Google","model":"Android SDK built for x86","brand":"google","apiVersion":"28","platformVersion":"9","carrierName":"Android","realDisplaySize":"1080x1920","displayDensity":420,"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":-50,"networkSpecifier":null,"SSID":null}},{"type":0,"typeName":"MOBILE","subtype":13,"subtypeName":"LTE","isConnected":true,"detailedState":"CONNECTED","state":"CONNECTED","extraInfo":"epc.tmobile.com","isAvailable":true,"isFailover":false,"isRoaming":false,"capabilities":{"transportTypes":"NET_CAPABILITY_MMS","networkCapabilities":"","linkUpstreamBandwidthKbps...
[ADB] Running '/Users/gremito/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell dumpsys window'
[AndroidDriver] Screen already unlocked, doing nothing
[UiAutomator2] Starting 'net.gremito.app.appiumtestforxamarin/net.gremito.app.appiumtestforxamarin.MainActivity and waiting for 'net.gremito.app.appiumtestforxamarin/net.gremito.app.appiumtestforxamarin.MainActivity'
[ADB] Running '/Users/gremito/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell am start -W -n net.gremito.app.appiumtestforxamarin/net.gremito.app.appiumtestforxamarin.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/6572217d-4279-4704-9475-7e2c95ba3153] with no body
[WD Proxy] Got response with status 200: {"sessionId":"6572217d-4279-4704-9475-7e2c95ba3153","value":null}
[ADB] Running '/Users/gremito/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell am force-stop net.gremito.app.appiumtestforxamarin'
[Instrumentation] .
[Logcat] Stopping logcat capture
[ADB] Removing forwarded port socket connection: 8200 
[ADB] Running '/Users/gremito/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 forward --remove tcp\:8200'
[UiAutomator2] Restoring hidden api policy to the device default configuration
[ADB] Running '/Users/gremito/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell settings delete global hidden_api_policy_pre_p_apps'
[ADB] Running '/Users/gremito/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell settings delete global hidden_api_policy_p_apps'
[ADB] Running '/Users/gremito/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell settings delete global hidden_api_policy'
[BaseDriver] Event 'newSessionStarted' logged at 1577003572240 (17:32:52 GMT+0900 (JST))
[MJSONWP] Encountered internal error running command: Error: Cannot start the 'net.gremito.app.appiumtestforxamarin' 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 '/Users/gremito/Library/Android/sdk/platform-tools/adb -P 5037 -s emulator-5554 shell am start -W -n net.gremito.app.appiumtestforxamarin/net.gremito.app.appiumtestforxamarin.MainActivity -S' timed out after 20000ms'. Try to increase the 20000ms adb execution timeout represented by 'adbExecTimeout' capability
[MJSONWP]     at ADB.startApp (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-adb/lib/tools/apk-utils.js:153:11)
[HTTP] <-- POST /wd/hub/session 500 39492 ms - 713
[HTTP] 
[HTTP] --> DELETE /wd/hub/session
[HTTP] {}
[HTTP] No route found. Setting content type to 'text/plain'
[HTTP] <-- DELETE /wd/hub/session 404 7 ms - 57
[HTTP] 

さいごに

引き続き調査を進めているので、解決次第アップデートします🙏

追記に解決方法をまとめました🙌

小ネタ①:Xcodeが古くXamarin.iOSが最新の場合

現在扱っているMBPは、Xcode10.1でiOSターゲットが12.1であり、その状態で最新のXamarin.iOSを扱うとiOSアプリをビルドすることができません。
次のようにターゲットを変えられるのですが、Xamarin.iOSが勝手にバージョン制御しているようでXcodeを最新にする必要があるようです。

スクリーンショット 2019-12-22 15.51.02.png スクリーンショット 2019-12-22 16.06.38.pngスクリーンショット 2019-12-22 16.06.15.png スクリーンショット 2019-12-22 16.10.30.png

小ネタ②:Xamarin.iOSは正常にAppium連携できる

別環境で試してみたところXamarin.iOSの方は正常にAppium連携できました笑

スクリーンショット 2019-12-23 11.36.33.png

追記

Appium Desktop App ver 1.9.1

Appiumのissueを確認したところ、似た環境で同じ現象が起きている方がAppiumのバージョン1.9で動作したことを確認したと言われていたため、Appiumのバージョン1.9.1を再インストールして試したところXamarinアプリとAppium連携できたことを確認できましたw

Appium Desktop App Newest Version

さらに最新のAppiumアプリでXamarinアプリのAppium連携方法が分かりました!

 

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?