Xamarin.UITests ApkFile 或 InstalledApp 尚未在 VS 中配置

标签 xamarin xamarin.ios xamarin.android xamarin.forms

我在 Visual Studio 中启动了一个新的 Xamarin 跨平台应用程序项目。

这只是您在 VS studio 中获得的模板。我已经在 Android 模拟器和真实 Android 设备上测试构建此应用程序,并且运行良好。启动欢迎使用 Xamarin Forms!

主要目的是在当前解决方案中将 Xamarin Test Cloud 与 Xamarmin.UITests 结合使用。

所以我在解决方案中添加了一个新项目(UI Test App(跨平台))。它还具有用于测试屏幕启动的模板。我已添加对 .IOS 和 .Android 项目的引用。

当我运行选定的测试时。我收到以下错误 ApkFile 或 InstalledApp 尚未配置

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

这应该打包设备上的 .Droid 项目启动并运行测试。我还确保未在 .Droid 项目的 Android 选项中选择使用共享运行时间。

如果我从外部引用 APK,这可以工作,但这不是我希望的工作方式。这应该适用于前面的内容,采用当前项目并运行测试。

 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();
}

最佳答案

看起来在某些情况下可能需要这样做。请参阅: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.

关于Xamarin.UITests ApkFile 或 InstalledApp 尚未在 VS 中配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42856962/

相关文章:

ios - 如何在 Xamarin Forms 中布局自定义 iOS View (UIStackView/UILabel)

c# - 使用 Mono Touch 的横向 iPad 应用程序

ios - 在 Xamarin 中更改 UITextField borderColor

c# - Xamarin:样式 TabWidget

c# - 避免 Xamarin Camera 的 OK Retry 按钮

sqlite - SQLite Xamarin : Query

windows - UWP 中用于 Xamarin Forms 项目的 AES 加密

ios - 从 iOS 应用程序将凭据传递到 Safari

android - 降低 Xamarin.Android + Visual Studio 的调试输出级别

visual-studio-2012 - 构建失败。 MonoDroid 不支持运行以前的版本