Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to resolve assembly : 'Java.Interop'

When I try to build the application I get an exception the following exception :

C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(681,3): error : Failed to resolve assembly: 'Java.Interop, Version=0.1.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'

I tried cleaning the project and building it again, also updated the Xamarin.Forms packages but still with no luck.

A little overview on the stack trace :

2>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(681,3): error : Failed to resolve assembly: 'Java.Interop, Version=0.1.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065' 2> Tool /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/bin/mtouch execution finished. (TaskId:153) 2> MTouch: 2016-07-05T14:27:15.8191415+05:30 - Finished (TaskId:153) 2> Output Item(s): _NativeLibrary= (TaskId:153) 2>Done executing task "MTouch" -- FAILED. (TaskId:153)

Has anyone received this error? I am running the latest Xamarin for Visual Studio.

like image 595
Akash Amin Avatar asked Jul 05 '16 09:07

Akash Amin


2 Answers

As mentioned in the comments above by @SushiHangover Java.Interop.dll is from Xamarin.Android and I was getting an error in Xamarin.IOS.

I had a reference of Mono.Android in PCL which is always referenced in Xamarin.IOS so indirectly I was referencing dll of Xamarin.Android to Xamarin.IOS. Removing the reference from PCL solved my problem.

like image 187
Akash Amin Avatar answered Oct 10 '22 17:10

Akash Amin


Step-by-step instructions on how to fish this one out, as it took me some time to find where the 'Android polluted' peace of code was.

  1. Unload your Common code project

enter image description here

  1. Open .csproj look for something like this

      <ItemGroup>
      <Reference Include="Mono.Android">
       <HintPath>..\..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v11.0\Mono.Android.dll</HintPath>
     </Reference>
    
  2. Delete this segment from csproj.

  3. Load the project

enter image description here

  1. Clean and rebuild the solution having iOS as startup Project, at this point, you will get a build error that will show which .cs file fails to build due to missing reference.
  2. Go there and move the mechanism to an Android specific project.
like image 44
Matas Vaitkevicius Avatar answered Oct 10 '22 17:10

Matas Vaitkevicius