AndroidX: [Regression] "Could not load file or assembly 'Mono.Cecil" error after update AndroidX.MediaRouter 1.1.0.2 > 1.1.0.3

Steps to Reproduce

  1. Update Xamarin.AndroidX.Mediarouter to 1.1.0.3 from 1.1.0.2 (in this version it works fine)
  2. Build solution in Microsoft App Center

Expected Behavior

Solution builds without errors.

Actual Behavior

Build errors appear:

“/Users/runner/work/1/s/TipCalculator/TipCalculator.Android/TipCalculator.Android.csproj” (PackageForAndroid;SignAndroidPackage target) (1) -> (_AndroidXCecilfy target) -> /Users/runner/.nuget/packages/xamarin.androidx.migration/1.0.7/buildTransitive/monoandroid90/Xamarin.AndroidX.Migration.targets(227,9): error : Could not load file or assembly ‘Mono.Cecil, Version=0.11.1.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e’ or one of its dependencies. [/Users/runner/work/1/s/TipCalculator/TipCalculator.Android/TipCalculator.Android.csproj] /Users/runner/.nuget/packages/xamarin.androidx.migration/1.0.7/buildTransitive/monoandroid90/Xamarin.AndroidX.Migration.targets(227,9): error : at Xamarin.AndroidX.Migration.CecilMigrator.Migrate (System.Collections.Generic.IEnumerable`1[T] assemblies) [0x00012] in <c3a66bc5909541309c1659496d4dbe3e>:0 [/Users/runner/work/1/s/TipCalculator/TipCalculator.Android/TipCalculator.Android.csproj] /Users/runner/.nuget/packages/xamarin.androidx.migration/1.0.7/buildTransitive/monoandroid90/Xamarin.AndroidX.Migration.targets(227,9): error : at Xamarin.AndroidX.Migration.BuildTasks.CecilfyFiles.Execute () [0x000e3] in <0de4c596f3444e36a044e54d012be7b8>:0 [/Users/runner/work/1/s/TipCalculator/TipCalculator.Android/TipCalculator.Android.csproj]

Version Information

Microsoft App Center Xamarin.Android 11.0 (Mono 6.12), Xamarin.Android 10.2 (Mono 6.8)

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 10
  • Comments: 91 (15 by maintainers)

Most upvoted comments

Really did not want to downgrade anything. Do we know when the fix is going to be published? Is there any ETA on the packages?

Waiting for this to be fixed asap. We are stuck because using a lower version is resulting in dialogs crashing on Android (aritchie/userdialogs#741), and using the current latest results in this build error on Azure DevOps.

My temporary work around:

The Error:

Error		
Could not load file or assembly 'Mono.Cecil, Version=0.11.1.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e' or one of its dependencies. The system cannot find the file specified.
   at Xamarin.AndroidX.Migration.CecilMigrator.Migrate(String source, String destination)
   at Xamarin.AndroidX.Migration.CecilMigrator.Migrate(IEnumerable`1 assemblies)
   at Xamarin.AndroidX.Migration.BuildTasks.CecilfyFiles.Execute()	App.Android

According to the detailed OUTPUT:

2>C:\Users\myusername\.nuget\packages\xamarin.androidx.migration\1.0.7\buildTransitive\monoandroid90\Xamarin.AndroidX.Migration.targets(227,9): error : Could not load file or assembly 'Mono.Cecil, Version=0.11.1.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e' or one of its dependencies. The system cannot find the file specified.
2>C:\Users\myusername\.nuget\packages\xamarin.androidx.migration\1.0.7\buildTransitive\monoandroid90\Xamarin.AndroidX.Migration.targets(227,9): error :    at Xamarin.AndroidX.Migration.CecilMigrator.Migrate(String source, String destination)
2>C:\Users\myusername\.nuget\packages\xamarin.androidx.migration\1.0.7\buildTransitive\monoandroid90\Xamarin.AndroidX.Migration.targets(227,9): error :    at Xamarin.AndroidX.Migration.CecilMigrator.Migrate(IEnumerable`1 assemblies)
2>C:\Users\myusername\.nuget\packages\xamarin.androidx.migration\1.0.7\buildTransitive\monoandroid90\Xamarin.AndroidX.Migration.targets(227,9): error :    at Xamarin.AndroidX.Migration.BuildTasks.CecilfyFiles.Execute()

My Resolution: After digging into the local machine folder: C:\Users\myusername\.nuget\packages\xamarin.androidx.migration\1.0.7\buildTransitive I discovered that the Mono.Cecil packages was NOT updating/propagating properly with version 0.11.1.0. Only the Mono.Cecil version 0.11.2 was there.

So I went to the currently Nuget installed version (0.11.1) at: C:\Users\myusername\.nuget\packages\mono.cecil and manually copied these files into: C:\Users\myusername\.nuget\packages\xamarin.androidx.migration\1.0.7\buildTransitive (overwriting files in there with version 0.11.2)

  • Mono.Cecil.dll
  • Mono.Cecil.Mdb.dll
  • Mono.Cecil.Mdb.pdb
  • Mono.Cecil.Pdb.dll
  • Mono.Cecil.Rocks.dll

My Installed (Affected) Nuget Package:

  • Mono.Cecil (0.11.1.0)
  • Xamarin.Androidx.Migration (1.0.7)
  • Xamarin.AndroidX.Lifecycle.LiveData (2.3.0.1-alpha03)
  • Xamarin.AndroidX.Browser (1.3.0.1-alpha01)
  • Xamarin.AndroidX.Legacy.Support.V4 (1.0.0.3)
  • Xamarin.AndroidX.MediaRouter (1.1.0.3)

My Conclusion: Nuget/Mono.Cecil is not propagating/inserting/copying the appropriate version into our projects/solutions.

This fixed it for me, for now at least… Hope this helps you guys out.

OBS: As per BacClunky idea, clearing out (deleting) C:\Users\myusername\.nuget\packages Also helps… ( I had over 20gb in there)``

Updated Note: My workaround does NOT remedy CI/CD (AppCenter & DevOps) as they will pull the flawed packages.

Hi, I have a similar error when building my app in an android emulator. please help me resolve this issue.

Error Could not load file or assembly ‘Mono.Cecil, Version=0.11.1.0, Culture=neutral, PublicKeyToken=50cebf1cce’ or one of its dependencies. The system cannot find the file specified. at Xamarin.AndroidX.Migration.CecilMigrator.Migrate(String source, String destination) at Xamarin.AndroidX.Migration.CecilMigrator.Migrate(IEnumerable`1 assemblies) at Xamarin.AndroidX.Migration.BuildTasks.CecilfyFiles.Execute() CoAway.Android

New set of packages pushed/published few minutes ago.

Please provide feedback if the issue is solved.

We are working on getting this out ASAP. Apologies for the delay. The issue is basically our signing system seems to be timing out with all these packages.

I go to .nuget\packages folder and delete all the folders xamarin.androidx.* then rebuild solution again. It builds successfully

Downgrade to AndroidX.MediaRouter 1.1.0.1 helped for me

Using solutions in this thread I suggest this combination:

  1. in your project: make sure that you have migrated from packages.config to PackageReference
  2. install package Xamarin.Androidx.Migration ver. 1.0.6.2
  3. close Visual Studio and wipe this: projectdir\obj projectdir\bin %userprofile%.nuget\packages

After all this steps I was able to solve the issue.

installing Xamarin.AndroidX.Migration version 1.0.6.2 resolved my build issue, it’s odd that it only broke on my windows laptop and not on my mac 🤷‍♂️

Reference directly from the Android project Xamarin.AndroidX.Migration version 1.0.6.2 which downgrades all AndroidX packages allowed me to build successful in AppCenter again.

@SoureMaster

Remove preview of Manifestmerger package. It is not needed anymore

You can add following code to your project file:

  <PropertyGroup>
    <AndroidManifestMerger Condition=" '$(AndroidManifestMerger)' == '' ">manifestmerger.jar</AndroidManifestMerger>
  </PropertyGroup>

Just an update: I merged all the bits for signing, so hopefully we will have packages in a hour or so if DevOps plays along.

I don’t have AndroidX.MediaRouter installed, but downgrading AndroidX.Migration package to 1.0.6.2 works for me.

FYI

Signing nugets on CI Azure Devops times out

Waiting for new signing to be implemented

https://github.com/xamarin/AndroidX/pull/163

@JMan7777 I’m so tired of those problems with DevOps. The tagged builds failed (mac only) and they run locally on 3 different Macs

Waiting for newly tagged builds

For me, downgrading is not working, and not even deleting the packages works for me. can someone(@burrowj ) please let me know where can we reference Xamarin.AndroidX.Migration version 1.0.6.2?

Reference directly from the Android project Xamarin.AndroidX.Migration version 1.0.6.2 which downgrades all AndroidX packages allowed me to build successful in AppCenter again.

This worked for me. Thanks.

Thanks @alexanderdp for your research and detailed work!!!

I think that might be it! Our versions of Cecil seem to be a bit out of sync. But it also is a bit weird. The build tasks build against 0.11.2, however the core part builds against 0.11.1. That is the reason, but, this is not even a minor version! Why is it strong named all the way?

Anyway, seems that we might be able to get a fix out soon. Thanks again for your work in getting to the bottom of this.

Having same issue after updating to latest Xamarin.AndroidX.* packages. Build crashes with the following error from file Xamarin.AndroidX.Migration.targets on Line 227

Error Could not load file or assembly ‘Mono.Cecil, Version=0.11.1.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e’ or one of its dependencies. The system cannot find the file specified. at Xamarin.AndroidX.Migration.CecilMigrator.Migrate(String source, String destination) at Xamarin.AndroidX.Migration.CecilMigrator.Migrate(IEnumerable`1 assemblies) at Xamarin.AndroidX.Migration.BuildTasks.CecilfyFiles.Execute() App.Android

I went to .nuget\packages folder and deleted all the folders xamarin.androidx.* then rebuild solution again. The build still fails. Have tried rolling back to a lower version of AndroidX.MediaRouter with NO luck, still crashes on build with same error.

Xamarin, please help us with this issue.

I have the same issue after installing Xamarin.AndroidX.Work.Runtime. This is the only package I have directly referenced.

Could not load file or assembly 'Mono.Cecil, Version=0.11.1.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e' or one of its dependencies. The system cannot find the file specified.
   at Xamarin.AndroidX.Migration.CecilMigrator.Migrate(String source, String destination)
   at Xamarin.AndroidX.Migration.CecilMigrator.Migrate(IEnumerable`1 assemblies)
   at Xamarin.AndroidX.Migration.BuildTasks.CecilfyFiles.Execute()	

Building against Android 10 SDK. I could remove AndroidX and use the old support libraries instead but I’d rather not.