Running Android Tests Project Fails due to "Could not load file or assembly 'Mono.Android"

NaGrNaGr USMember
edited November 8 in Xamarin.Android

All my tests are getting this error:
System.IO.FileNotFoundException: Could not load file or assembly 'Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065' or one of its dependencies. The system cannot find the file specified.

I have made sure shared runtime is not on. I switched to Release build and made sure shared runtime is not on. I also get this error when running in Debug build.

I see that Mono.Android is a reference in my references list. But I do not know what it is for, and why it can't be found.

My test.cs file:
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using ProjectName;

[TestClass]
public class ProjectNameTests
{
    [TestMethod]
    public void GetVariable_WhenAction_ThenReturn2040()
    {
        var variable= LogAnalyzer.GetVariable();

        Assert.Equals(variable, 2040);
    }
}  

Answers

  • GrNaGrNa USMember
    edited November 11

    Got my tests working.. just in case it helps others:

    (1) Choosing between Unit Test App (Android) and UI Test App (Xamarin | Android).. I should have chosen neither? Going with Unit Test "Project" for .Net worked for me.. though in the end thats what I had, but it didn't make the Mono error go away.
    (2) Maybe the test was trying to run my actual ProjectName, and therefore Mono.Android (which I believe is the glue library between c# and java android) , which it couldn't do for the test (as there is no emulator involved) and thats not what I wanted anyway. I just want to test business logic.. So moved all my business logic into a new Class Library project I named ProjectName.BusinessLogic

    Did learn that its also possible to make tests that fake pressing buttons and interacting with your app.. which is neat.. but thats not what I was doing here. I think the UI Test App would have been the correct project for that..

Sign In or Register to comment.