user2968227
user2968227

Reputation: 53

Xamarin.UITests ApkFile or InstalledApp has not been configured in VS

I have started a new Xamarin Cross Platform App project in visual studio.

This is just the template you get in VS studio. I have testing building this app on an Android emulator and real Android device and works fine. Launches the Welcome to Xamarin Forms!

The main purpose is to use Xamarin Test Cloud with Xamarmin.UITests within the current solution.

So I have added a new project to the solution (UI Test App (cross platform)). That also has the template for testing the screen launches. I have added the references to the .IOS and .Android projects.

When I run the selected tests. I get the following error ApkFile or InstalledApp has not been configured

if (platform == Platform.Android)
{
     return ConfigureApp
     .Android
     .StartApp();
}

This should package up the .Droid project launch on the device and run the tests. I have also made sure USE SHARED RUN TIME is not selected in the Android Options for the .Droid project.

If I reference the APK externally this works but that is not how I want this to work. This should work in the the previous content taking the current project and running the tests.

 if (platform == Platform.Android)
{
    return ConfigureApp
    .Android
    .ApkFile(@"C:\Users\frasera\Documents\Visual Studio 2017\Projects\App6\App6\App6.Android\bin\Debug\App6.Android.apk")
                .StartApp();
}

Upvotes: 4

Views: 3655

Answers (1)

jgoldberger - MSFT
jgoldberger - MSFT

Reputation: 6098

Looks like that may be required in some circumstances. See: https://developer.xamarin.com/guides/testcloud/uitest/working-with/running-tests-in-ide/#Running_Android_6.0_Applications_from_the_IDE

When the IDE installs an Android 6.0 app for the first time, it does not grant all permissions required by the application. The workaround for this is to use UITest to install and start the application:

ConfigureApp.Android.Debug().ApkFile(apkpath).StartApp ()

Do use ApkFile() and do not use PreferIdeSettings(). This will force UITest to install instead of the IDE.

Upvotes: 3

Related Questions