Forum Xamarin.Android

Android UI test fail to execute adb.exe

I am running Xmarin android Player on Mac and I am writing UITest for android in Visual studio in windows in VMware environment as a beginner, I never wrote test, this is first time I am writing tests for an application, I followed this tutorial to write test for android ( https://developer.xamarin.com/guides/testcloud/uitest/intro-to-uitest/ ) but unfortunately I am getting following error

Test Name:  AppLaunches
Test FullName:  myplano.android.tests.Tests(Android).AppLaunches
Test Source:    c:\Users\plano\Documents\Visual Studio 2013\Projects\xamarin_myplano\myplano.android.tests\Tests.cs : line 40
Test Outcome:   Failed
Test Duration:  0:00:27.51

Result Message: SetUp : System.Exception : Failed to execute: C:\Users\plano\AppData\Local\Android\android-sdk\temp\PlatformToolPackage.old01\adb.exe devices - exit code: -1073741515
Result StackTrace:  
at Xamarin.UITest.Shared.Processes.ProcessRunner.Run(String path, String arguments)
at Xamarin.UITest.Shared.Android.Queries.QueryAdbDevices.Execute(IProcessRunner processRunner, IAndroidSdkTools androidSdkTools)
at Xamarin.UITest.Shared.Execution.Executor.<Execute>c__AnonStorey2`3.<>m__0()
at Xamarin.UITest.Shared.Execution.Executor.WrapQuery[TResult](Func`1 queryFunc)
at Xamarin.UITest.Shared.Execution.Executor.Execute[TResult,TDep1,TDep2](IQuery`3 query)
at Xamarin.UITest.Android.LocalAndroidAppInitializer.GetDeviceSerial(IAndroidAppConfiguration appConfiguration)
at Xamarin.UITest.Android.LocalAndroidAppInitializer.PrepareEnvironment()
at Xamarin.UITest.Android.AndroidApp..ctor(IAndroidAppConfiguration appConfiguration)
at Xamarin.UITest.Configuration.AndroidAppConfigurator.StartApp(AppDataMode appDataMode)
at myplano.android.tests.AppInitializer.StartApp(Platform platform) in c:\Users\plano\Documents\Visual Studio 2013\Projects\xamarin_myplano\myplano.android.tests\AppInitializer.cs:line 13
at myplano.android.tests.Tests.BeforeEachTest() in c:\Users\plano\Documents\Visual Studio 2013\Projects\xamarin_myplano\myplano.android.tests\Tests.cs:line 35

Here is my code

using NUnit.Framework;
using Xamarin.UITest;
using Xamarin.UITest.Queries;
using Xamarin.UITest.Android;

namespace myplano.android.tests
{
    [TestFixture(Platform.Android)]
    public class Tests
    {
        //AndroidApp app;
        IApp app;
        Platform platform;

        public Tests(Platform platform)
        {
            this.platform = platform;
        }

        [SetUp]
        public void BeforeEachTest()
        {
            // TODO: If the Android app being tested is included in the solution then open
            // the Unit Tests window, right click Test Apps, select Add App Project
            // and select the app projects that should be tested.
            //app = ConfigureApp
               // .Android
                // TODO: Update this path to point to your Android app and uncomment the
                // code if the app is not included in the solution.
                //.ApkFile ("../../../Android/bin/Debug/UITestsAndroid.apk")
                //.StartApp();
            app = AppInitializer.StartApp(platform);
        }

        [Test]
        public void AppLaunches()
        {
            //app.Screenshot("First screen.");
            app.Back();
        }
    }
}


using Xamarin.UITest;

namespace myplano.android.tests
{
   public class AppInitializer
    {
       public static IApp StartApp(Platform platform)

        {

          if (platform == Platform.Android)
          {
              return ConfigureApp

                  .Android

                  .ApkFile(@"C:\Users\plano\Documents\Visual Studio 2013\Projects\xamarin_myplano\myplano\myplano.android\bin\Debug\com.planopunkt.myplano.apk")

                  .StartApp();

          }
           return ConfigureApp
               .iOS
               .StartApp();

       }

   }
}

Please help to resolve this issue.

Best Answers

  • JimBennettJimBennett GBXamarin Team, Insider, University, Developer Group Leader ✭✭✭✭
    Accepted Answer

    Nope - but have you tried upgrading to the latest UITest nuget package? They're on 1.3.2 now so may fix your issue. I'm using it with no issues.

Answers

  • EmyMa341EmyMa341 USMember ✭✭
    edited February 2016

    I solved the above error, now I am getting new error while running android UI test, my code is same as above

    Test Name: App
    Test FullName: myplano.android.tests.Tests.App
    Test Source: c:\Users\makhan\Documents\Visual Studio 2013\Projects\xamarin_myplano\myplano.android.tests\Tests.cs : line 44
    Test Outcome: Failed
    Test Duration: 0:00:00,507

    Result Message: SetUp : System.InvalidOperationException : The sequence contains no elements.
    Result StackTrace:
    bei System.Linq.Enumerable.Single[TSource](IEnumerable1 source) bei Xamarin.UITest.Shared.Android.Queries.QueryKeyStoreKeyType.ExtractKeyType(ProcessResult processResult) bei Xamarin.UITest.Shared.Android.Queries.QueryKeyStoreKeyType.Execute(IProcessRunner processRunner, IJdkTools jdkTools) bei Xamarin.UITest.Shared.Execution.Executor.<Execute>c__AnonStorey23.<>m__0()
    bei Xamarin.UITest.Shared.Execution.Executor.WrapQuery[TResult](Func1 queryFunc) bei Xamarin.UITest.Shared.Execution.Executor.Execute[TResult,TDep1,TDep2](IQuery3 query)
    bei Xamarin.UITest.Shared.Android.KeyStore..ctor(IExecutor executor, FileInfo keyStoreFile, String keyAlias, String storePassword, String keyPassword)
    bei Xamarin.UITest.Android.LocalAndroidAppInitializer.GetDefaultKeyStore(ArtifactFolder artifactFolder)
    bei Xamarin.UITest.Android.LocalAndroidAppInitializer.PrepareApkFiles(IAndroidAppConfiguration appConfiguration, ArtifactFolder artifactFolder)
    bei Xamarin.UITest.Android.AndroidApp..ctor(IAndroidAppConfiguration appConfiguration)
    bei Xamarin.UITest.Configuration.AndroidAppConfigurator.StartApp(AppDataMode appDataMode)
    bei myplano.android.tests.Tests.BeforeEachTest() in c:\Users\makhan\Documents\Visual Studio 2013\Projects\xamarin_myplano\myplano.android.tests\Tests.cs:Zeile 31.

    The above exception is on this line of code
    app = ConfigureApp
    .Android
    .ApkFile("C:/Users/makhan/Documents/com.planopunkt.myplano.apk")
    .StartApp();

    If I reference the android project without giving apk file still same error

  • EmyMa341EmyMa341 USMember ✭✭
    edited February 2016

    Anyone faced same situation ?

  • JimBennettJimBennett GBXamarin Team, Insider, University, Developer Group Leader ✭✭✭✭
    Accepted Answer

    Nope - but have you tried upgrading to the latest UITest nuget package? They're on 1.3.2 now so may fix your issue. I'm using it with no issues.

  • EmyMa341EmyMa341 USMember ✭✭

    Thanks @JimBennett for your response, this was all about UItest and I fixed it, I didn't upgrading to latest version but for now downgrading worked but for sure I will upgrade to latest version. One thing more is there any quick start documentation or tutorial for wring unit test for Xamarin.Android, I didn't find any tutorial related to specifically android.

  • JimBennettJimBennett GBXamarin Team, Insider, University, Developer Group Leader ✭✭✭✭

    UI Test is pretty generic - works for iOS and Android in much the same way so any tutorial will work. The Xamarin docs are a pretty good starting point

    https://developer.xamarin.com/guides/testcloud/uitest/

  • emysa341emysa341 USMember

    @JimBennett I am getting this error again, I am on latest version of Xamarin.UITest, I am getting this error again as I upgraded my Xamarin Visual studio to latest version, Here is error log

    Result Message: SetUp : System.Exception : Failed to execute: C:\Users\plano\AppData\Local\Android\android-sdk\temp\PlatformToolPackage.old01\adb.exe devices - exit code: -1073741515
    Result StackTrace:
    at Xamarin.UITest.Shared.Processes.ProcessRunner.Run(String path, String arguments)
    at Xamarin.UITest.Shared.Android.Queries.QueryAdbDevices.Execute(IProcessRunner processRunner, IAndroidSdkTools androidSdkTools)
    at Xamarin.UITest.Shared.Execution.Executor.c__AnonStorey23.<>m__0() at Xamarin.UITest.Shared.Execution.Executor.WrapQuery[TResult](Func1 queryFunc)
    at Xamarin.UITest.Shared.Execution.Executor.Execute[TResult,TDep1,TDep2](IQuery`3 query)
    at Xamarin.UITest.Android.LocalAndroidAppInitializer.GetDeviceSerial(IAndroidAppConfiguration appConfiguration)
    at Xamarin.UITest.Android.LocalAndroidAppInitializer.PrepareEnvironment()
    at Xamarin.UITest.Android.AndroidApp..ctor(IAndroidAppConfiguration appConfiguration)
    at Xamarin.UITest.Configuration.AndroidAppConfigurator.StartApp(AppDataMode appDataMode)
    at UITest1.Tests.BeforeEachTest() in c:\Users\plano\Documents\Visual Studio 2013\Projects\xamarin_myplano\UITest1\Tests.cs:line 22

  • SajidSidiSajidSidi USUniversity ✭✭

    I am getting Similar issue.

    My Story is like... I am a new in Xamarin UITest and while beginning it was working fine but once I get lates .apk from our Dev. Team and it started to throw errors for vertual devices only, although it is working fine with Real Devices. but not working with Genymotion simulators. Please help...

    Test Name: AppLaunches
    Test FullName: ZeroChaosUITest.Tests(Android).AppLaunches
    Test Source: C:\SAJID SIDI\Xamarin\Projects\ZeroChaosUITest-master\ZeroChaosUITest\Tests\Tests.cs : line 30
    Test Outcome: Failed
    Test Duration: 0:00:01.996

    Result StackTrace:
    at Xamarin.UITest.Shared.Processes.ProcessRunner.Run(String path, String arguments, IEnumerable1 noExceptionOnExitCodes) at Xamarin.UITest.Shared.Android.Adb.AdbProcessRunner.Run(String adbArguments, Int32[] noExceptionsOnExitCodes) at Xamarin.UITest.Shared.Android.Commands.CommandAdbInstallPackage.<Execute>c__AnonStorey0.<>m__0(String args) at Xamarin.UITest.Shared.Android.Commands.CommandAdbInstallPackage.ExecuteInner(Func2 adbShell, Int32 deviceSdkVersion)
    at Xamarin.UITest.Shared.Android.Commands.CommandAdbInstallPackage.Execute(AdbProcessRunner processRunner, IExecutor executor)
    at Xamarin.UITest.Shared.Execution.Executor.Execute[TDep1,TDep2](ICommand`2 command)
    at Xamarin.UITest.Shared.Android.LocalAndroidAppLifeCycle.InstallApps(ApkFile[] apkFiles)
    at Xamarin.UITest.Shared.Android.LocalAndroidAppLifeCycle.EnsureInstalled(ApkFile appApkFile, ApkFile testServerApkFile)
    at Xamarin.UITest.Android.AndroidApp..ctor(IAndroidAppConfiguration appConfiguration, IExecutor executor)
    at Xamarin.UITest.Configuration.AndroidAppConfigurator.StartApp(AppDataMode appDataMode)
    at ZeroChaosUITest.AppInitializer.StartApp(Platform platform) in C:\SAJID SIDI\Xamarin\Projects\ZeroChaosUITest-master\ZeroChaosUITest\AppInitializer.cs:line 26
    at ZeroChaosUITest.Tests.BeforeEachTest() in C:\SAJID SIDI\Xamarin\Projects\ZeroChaosUITest-master\ZeroChaosUITest\Tests\Tests.cs:line 25
    Result Message:
    SetUp : System.Exception : Failed to execute: C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe -s 192.168.202.101:5555 install -g "C:\Users\ssidi\AppData\Local\Temp\uitest\a-77710D38FAFC1E54041539C1991A3D35B8C9FC4E\final-A7778C8A1BD5066ABCC133FD188BF7ECA8F9AE65.apk" - exit code: 1
    Failed to install C:\Users\ssidi\AppData\Local\Temp\uitest\a-77710D38FAFC1E54041539C1991A3D35B8C9FC4E\final-A7778C8A1BD5066ABCC133FD188BF7ECA8F9AE65.apk: Failure [INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries, res=-113]

Sign In or Register to comment.