AppCenter中Xamarin.Android的'App Does Launch'测试失败求助
From your test logs, the core issue is the Calabash server failing to launch (error code 104) when executing the instrumentation command—even though your app deploys successfully on your local Pixel XL Android 8.0 emulator. Let’s break down the key issues and actionable fixes:
Critical Errors to Focus On
These lines from the log point to the root problems:
SetUp : System.Exception : Failed to execute: adb shell am instrument -e "target_package" "com.companyname.MeStudentV1" -e "main_activity" "null" ... exit code: 1 ... Error while starting {"message"=>"Waited for Calabash server on 37280. Did not launch.", "device_id"=>"88b18273-1f47-476c-be16-6d0c7ce1c349", "error_code"=>104}
Step-by-Step Fixes
1. Fix Missing Main Activity Configuration
Notice the main_activity" "null in the adb command—this means UITest can’t locate your app’s main activity.
- In your UITest project’s
SetUpmethod, explicitly specify the full path to your main activity:app = ConfigureApp.Android .EnableLocalScreenshots() .MainActivity("com.companyname.MeStudentV1.MainActivity") // Replace with your actual activity class path .StartApp(); - Verify your AndroidManifest.xml has the correct intent-filter for the main activity to ensure it’s marked as the launchable entry point:
<activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
2. Ensure Consistent Signing for App and Test APKs
AppCenter requires your main app APK and the UITest instrumentation APK to be signed with the same keystore.
- If you’re using a release keystore for AppCenter uploads, make sure your UITest project is also signed with this keystore (not the default debug keystore).
- Double-check that the
target_packagein the instrumentation command matches your app’s package name exactly (com.companyname.MeStudentV1).
3. Validate Calabash Instrumentation Setup
Confirm your Android project has the correct Calabash integration:
- Upgrade
Xamarin.UITestto the latest stable version (your log uses 2.2.1—older versions may have compatibility issues with AppCenter’s test environment). - Verify your AndroidManifest.xml includes the required instrumentation entry:
<instrumentation android:name="sh.calaba.instrumentationbackend.CalabashInstrumentationTestRunner" android:targetPackage="com.companyname.MeStudentV1" /> - Ensure the
com.companyname.MeStudentV1.testpackage (referenced in the log) exists and is correctly linked to your UITest project.
4. Rule Out Port Conflicts (Less Likely but Worth Testing)
The log mentions waiting for Calabash on port 37280. Try forcing a different port in your UITest setup to avoid potential conflicts in AppCenter’s environment:
app = ConfigureApp.Android .Port(37778) // Use an alternative unused port .StartApp();
5. Re-upload Clean Test Assets to AppCenter
Corrupted uploads can cause unexpected failures:
- Clean your solution, rebuild both the Android app and UITest project from scratch.
- Re-upload the updated APK and UITest assemblies to AppCenter, ensuring you select the correct build artifacts.
Full Test Log Reference
NUnit-Console version 2.6.3.13283 Copyright (C) 2002-2012 Charlie Poole. Copyright (C) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov. Copyright (C) 2000-2002 Philip Craig. All Rights Reserved. Runtime Environment - OS Version: Unix 17.4.0.0 CLR Version: 4.0.30319.42000 ( Mono 4.0 ( 5.2.0.224 (d15-3/14f2c81 Thu Aug 24 10:33:52 EDT 2017) ) ) ProcessModel: Default DomainUsage: Single Execution Runtime: mono-4.0 Installing test cloud reporter. Connected to Xamarin.UITest. Run list: runlist.txt .15-03-2018 13:05:06.922 +01:00 - 0 - Full log file: /Volumes/Data/xamarin/workspaces/82e558c3-7406-4ce0-8cde-1014329f0388/workspace/tmp/uitest/log-2018-03-15_13-05-06-914.txt 15-03-2018 13:05:07.047 +01:00 - 124 - Android test running Xamarin.UITest version: 2.2.1 15-03-2018 13:05:07.076 +01:00 - 153 - Using XAMARIN_TEST_CLOUD configuration override. 15-03-2018 13:05:07.996 +01:00 - 1073 - Initializing Android app with apk: /Volumes/Data/xamarin/workspaces/82e558c3-7406-4ce0-8cde-1014329f0388/workspace/app.apk FTook final screenshot. { Title: "After test", FileName: "/Volumes/Data/xamarin/workspaces/82e558c3-7406-4ce0-8cde-1014329f0388/workspace/screenshot-final-99776814e79442b7b1a0fba447e5c853.png", ElapsedMilliseconds: 12250 } Completed run. 19 events collected. [[[ XTC-Output-Path: '/Volumes/Data/xamarin/workspaces/82e558c3-7406-4ce0-8cde-1014329f0388/workspace/tmp/TestRun-20180315-120905-6895' ]]] Tests run: 1, Errors: 1, Failures: 0, Inconclusive: 0, Time: 239.2881854 seconds Not run: 0, Invalid: 0, Ignored: 0, Skipped: 0 Errors and Failures: 1) SetUp Error : AppCenter.UITest.Android.Tests.AppDoesLaunch SetUp : System.Exception : Failed to execute: /Volumes/Data/xamarin/pipeline/versions/273b31185a32748d5aac56b7a2a964a8327c3225/adt/sdk/platform-tools/adb shell am instrument -e "target_package" "com.companyname.MeStudentV1" -e "main_activity" "null" -e "debug" "false" -e "test_server_port" "37777" -e "class" "sh.calaba.instrumentationbackend.InstrumentationBackend" com.companyname.MeStudentV1.test/sh.calaba.instrumentationbackend.CalabashInstrumentationTestRunner - exit code: 1 /Volumes/Data/xamarin/pipeline/versions/273b31185a32748d5aac56b7a2a964a8327c3225/adt/sdk/platform-tools/adb:407: warning: already initialized constant ARGV Parse am instrument -e target_package com.companyname.MeStudentV1 -e main_activity null -e debug false -e test_server_port 37777 -e class sh.calaba.instrumentationbackend.InstrumentationBackend com.companyname.MeStudentV1.test/sh.calaba.instrumentationbackend.CalabashInstrumentationTestRunner {:instrumentation=>"com.companyname.MeStudentV1.test/sh.calaba.instrumentationbackend.CalabashInstrumentationTestRunner", :instrumentation_name=>"sh.calaba.instrumentationbackend.CalabashInstrumentationTestRunner", :main_activity=>"null", :class=>"sh.calaba.instrumentationbackend.InstrumentationBackend", :target_package=>"com.companyname.MeStudentV1", :package_name=>"com.companyname.MeStudentV1.test"} Parse am instrument -e target_package com.companyname.MeStudentV1 -e main_activity null -e debug false -e test_server_port 37777 -e class sh.calaba.instrumentationbackend.InstrumentationBackend com.companyname.MeStudentV1.test/sh.calaba.instrumentationbackend.CalabashInstrumentationTestRunner {:instrumentation=>"com.companyname.MeStudentV1.test/sh.calaba.instrumentationbackend.CalabashInstrumentationTestRunner", :instrumentation_name=>"sh.calaba.instrumentationbackend.CalabashInstrumentationTestRunner", :main_activity=>"null", :class=>"sh.calaba.instrumentationbackend.InstrumentationBackend", :target_package=>"com.companyname.MeStudentV1", :package_name=>"com.companyname.MeStudentV1.test"} /Volumes/Data/xamarin/pipeline/versions/273b31185a32748d5aac56b7a2a964a8327c3225/adt/sdk/platform-tools/adb:117:in `shel': Error while starting {"message"=>"Waited for Calabash server on 37280. Did not launch.", "device_id"=>"88b18273-1f47-476c-be16-6d0c7ce1c349", "error_code"=>104}, 503, {"message":"Waited for Calabash server on 37280. Did not launch.","device_id":"88b18273-1f47-476c-be16-6d0c7ce1c349","error_code":104}. (RuntimeError) from /Volumes/Data/xamarin/pipeline/versions/273b31185a32748d5aac56b7a2a964a8327c3225/base_gems/gems/thor-0.18.1/lib/thor/command.rb:27:in `run' from /Volumes/Data/xamarin/pipeline/versions/273b31185a32748d5aac56b7a2a964a8327c3225/base_gems/gems/thor-0.18.1/lib/thor/invocation.rb:120:in `invoke_command' from /Volumes/Data/xamarin/pipeline/versions/273b31185a32748d5aac56b7a2a964a8327c3225/base_gems/gems/thor-0.18.1/lib/thor.rb:363:in `dispatch' from /Volumes/Data/xamarin/pipeline/versions/273b31185a32748d5aac56b7a2a964a8327c3225/base_gems/gems/thor-0.18.1/lib/thor/base.rb:439:in `start' from /Volumes/Data/xamarin/pipeline/versions/273b31185a32748d5aac56b7a2a964a8327c3225/adt/sdk/platform-tools/adb:413:in `<main>' at Xamarin.UITest.Shared.Processes.ProcessRunner.Run (System.String path, System.String arguments, System.Collections.Generic.IEnumerable`1[T] noExceptionOnExitCodes) [0x00059] in <5745119407a04120bc96f6ab09d7913e>:0 at Xamarin.UITest.Shared.Android.Adb.AdbProcessRunner.Run (System.String adbArguments, System.Int32[] noExceptionsOnExitCodes) [0x00011] in <5745119407a04120bc96f6ab09d7913e>:0 at Xamarin.UITest.Shared.Android.Commands.CommandAdbInstrument.Execute (Xamarin.UITest.Shared.Android.Adb.AdbProcessRunner processRunner) [0x00081] in <5745119407a04120bc96f6ab09d7913e>:0 at Xamarin.UITest.Shared.Execution.Executor.Execute[TDep1] (Xamarin.UITest.Shared.Execution.ICommand`1[TDep1] command) [0x0000c] in <5745119407a04120bc96f6ab09d7913e>:0 at Xamarin.UITest.Shared.Android.TestCloudAndroidAppLifeCycle.LaunchApp (Xamarin.UITest.Shared.Android.ApkFile appApkFile, Xamarin.UITest.Shared.Android.ApkFile testServerApkFile, System.Int32 testServerPort) [0x0004c] in <5745119407a04120bc96f6ab09d7913e>:0 at Xamarin.UITest.Android.AndroidApp..ctor (Xamarin.UITest.Configuration.IAndroidAppConfiguration appConfiguration, Xamarin.UITest.Shared.Execution.IExecutor executor) [0x001c1] in <5745119407a04120bc96f6ab09d7913e>:0 at Xamarin.UITest.Android.AndroidApp..ctor (Xamarin.UITest.Configuration.IAndroidAppConfiguration appConfiguration) [0x00000] in <5745119407a04120bc96f6ab09d7913e>:0 at Xamarin.UITest.Configuration.AndroidAppConfigurator.StartApp (Xamarin.UITest.Configuration.AppDataMode appDataMode) [0x00017] in <5745119407a04120bc96f6ab09d7913e>:0 at AppCenter.UITest.Android.Tests.SetUp () [0x00010] in <bcdaf2f196224d76ad22fb1c6eb5ef28>:0 at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&) at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <48b95f3df5804531818f80e28ec60191>:0 WARNING: The runtime version supported by this application is unavailable. Using default runtime: v4.0.30319
内容的提问来源于stack exchange,提问作者John Kenneth Furog

