Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin.UITesting NU1201 Error: Android 8.1 Is incompatible with .NETFramework 4.6.1

Have been having a little issue for the last couple of days now where I will create a new Xamarin Forms project on Visual Studio 2017 and add a Xamarin.UITest Cross-Platform Test Project for unit testing I recieve a series of NU1201 Errors when I reference the .Android App in the UITest Project.

Here is the exact error i get:

Error NU1201    Project App1.Android is not compatible with net461 (.NETFramework,Version=v4.6.1) / win-x64. Project App1.Android supports: monoandroid81 (MonoAndroid,Version=v8.1)    

I have played around with the Android version numbers to see if the UITesting package doesnt support the latest android but no matter what version of android i target the problem remains the same.

Here is a screenshot of the project. enter image description here All the code is unchanged from the default project and runs in the simulator fine but only produces these errors when the Android app is referenced to the UITest project.

like image 452
Fakelzaman Avatar asked Jul 12 '18 03:07

Fakelzaman


People also ask

Is Xamarin deprecated Android?

Not dead but possibly moribund. In May 2020, Microsoft announced that Xamarin. Forms, a major component of its mobile app development framework, would be deprecated in November 2021 in favour of a new . Net based product called MAUI - Multiform App User Interface.

What .NET framework does Xamarin use?

Xamarin apps use Mono as the . NET implementation for running the apps and you can create these projects from Visual Studio or Visual Studio for Mac.

Does Xamarin support .NET 5?

NET 5 support in Xamarin iOS, Xamarin Android and of course UWP.

Does Xamarin work with iOS and Android?

Xamarin. Forms is an open source mobile UI framework from Microsoft for building iOS, Android, & Windows apps with . NET from a single shared codebase.


1 Answers

Solved it after many more hours of testing and trialling. Instead of adding the Android project to the references, Within the AppInitializer I added another method to the StartApp() call like so:

public class AppInitializer
{
    public static IApp StartApp(Platform platform)
    {
        if (platform == Platform.Android)
        {
            return ConfigureApp.Android.InstalledApp("com.companyname.App1").StartApp();
        }

        return ConfigureApp.iOS.StartApp();
    }
}

Therefore once I had already run the app via the emulator for the first time and installed on the device, the UITest simply uses the installed APK on the emulator instead of the project.

like image 85
Fakelzaman Avatar answered Oct 10 '22 11:10

Fakelzaman