Xamarin.UITests Android device not detected or not working

I cannot run Xamarin.UITests on any android simulator / emulator. Any suggestions? When trying to run the following errors:

Google emulator:

SetUp: System.Exception: Unable to run on physical device without activation. The full version is available for Xamarin Test Cloud customers, for more information contact sales@xamarin.com If you are already a Xamarin Test Cloud customer, you can provide your api in one of the following ways: * Adding it ConfigureApp using the ApiKey method * Setting a variable XTC_API_KEY environment * Add the following attribute to the Properties / AssemblyInfo.cs file: [assembly: Xamarin.UITest.TestCloudApiKey (YOUR_API_KEY)] * Place the xtc_api key file containing your api key in the upstream directory from the test build.

Xamarin Android Player:

SetUp: System.Exception: No connected devices are connected

GenyMotion:

SetUp: System.Exception: Failed to execute: / users / erikandersen / Library / Developer / Xamarin / android-sdk-macosx / platform-tools / adb devices - exit code: 1 cannot bind 'tcp: 5037' ADB server not ACK * failed to start daemon * error: adb server is out of date. By killing ...

After updating GenyMotion to 2.3.1, I now get the following error:

SetUp: System.Exception: Application installation error with output: 12050 KB / s (11199602 bytes in 0.907 s) pkg: /data/local/tmp/final-xxxxxx.apk Error [INSTALL_FAILED_CPU_ABI_INCOMPATIBLE]

NUnit Code

    AndroidApp _app;
    public string PathToAPK { get; set; }

    [TestFixtureSetUp]
    public void BeforeAll ()
    {
        var path = new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath;
        var info = new FileInfo(path);
        var directory = info.Directory.Parent.Parent.Parent.FullName;

        PathToAPK = Path.Combine(directory, "Android", "bin", "Debug", "Demo.Android.apk");
    }

    [SetUp]
    public void BeforeEach ()
    {
        _app = ConfigureApp.Android.ApkFile (PathToAPK).StartApp ();
    }

    [Test]
    public void TestInvalidEmail ()
    {
        _app.EnterText (c => c.Class ("UITextField"), "");
    }

      

TestInvalidEmail () is never called because NUnit doesn't work on

_app = ConfigureApp.Android.ApkFile (PathToAPK).StartApp ();

      

Background:

I am using Xamarin.UITests for an iOS / Android app I am developing and we have Android issues. iOS works great. I wrote each test twice, once in C # and once in Ruby using calabash to isolate the problem. Calabash works fine, but any C # NUnit testing project cannot connect to whatever emulator I run.

What I have tried:

  • Make sure the emulator is already running before running tests.
  • Make sure only one emulator is running
  • Restarting adb server
  • Trying multiple types of emulators (i.e. Xamarin Android Player, Gennymotion and Google Emulator)
+3


source to share


2 answers


So, after hours of working on this, this fixed it:

  • GennyMotion update to version 2.3.1
  • Delete my old GenyMotion simulator (Nexus 4) and create a new one
  • Add support for all ABIs in Android Build settings

Android Project> Options> Android Build> Advanced tab> Supported ABIs> Check "armeabi, armeabi-v7a, x86"> OK

  1. Generate new .apk file via terminal (while in android project directory)

/ usr / bin / xbuild / t: Package / p: Configuration = Release.csproj

  1. Resetting .apk using calabash-android


calabash-android resign./bin/Release/.apk

  1. In Xamarin Studio set my startup project as a UITest project
  2. Launch GenyMotion simulator
  3. Debug tests in Debug configuration with only GenyMotion simulator active

And it worked! I still cannot run UI tests using Google Emulator or Xamarin Android Player. Funny, I also cannot debug my Android project using GenyMotion. This is only useful for UITests. Here's my current setup:

Xamarin Android Player - Normal Debugging

GenyMotion - UITests

+2


source


I had the same problem and was fixed by installing ApiKey while setting up ConfigureApp.

    [SetUp]
    public void SetUp()
    {
            _app = ConfigureApp.iOS.AppBundle(PathToIPA).ApiKey("YOUR_API_KEY_HERE").StartApp();
    }

      



As in here . Just install your ApiKey.

Note. I didn't have this issue with Xamarin Android Player. I didn't have this AVD issue with Android 5.0 emulator. I only had AVD issue running Android 4.0.3 emulator.

0


source







All Articles