C# Xamarin Java.Interop error?

14,897

Solution 1

You can found it here

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\Java.Interop.dll

then :

  1. Go to your Android project
  2. Right Click in reference and choose "Add Reference"
  3. Browse file location
  4. Add and done

if you still get error, try to rebuild your project

Solution 2

I go the same error after the last update. You just have to add the reference to Java.Interop to resolve the problem.

  1. Go to your Android project
  2. Right Click in reference and choose "Add Reference"
  3. On Assembly, look for Java.Interop and add it
  4. Rebuild your project

If you need some screenshots, I can provide them later.

Solution 3

In my case it was a bit different, I couldn't find monoandroid folder in

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework. 

So on further I searched and found it in

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid

This might be the case with someone else.

Solution 4

You can hover over the offending line and see the missing DLL.

Line complaining about missing reference

Now add the missing reference;

  1. Open the Solution Explorer, and within References right click, and select Add ReferenceAdd Reference from Solution Explorer

  2. Within the Reference Manager click Browse, and Browse again. Add reference

  3. In the file dialog copy and paste this path:

    C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\

Go to DLL path

Click Java.Interop.dll

Add file

  1. Okay the Reference Manager

Solution 5

You can directly copy the assembly Java.Interop.dll from the C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0 to the bin/Debug folder of your project to resolve the issue.

This procedure perfectly worked for me.

Thanks,

Share:
14,897
highwaydog
Author by

highwaydog

Updated on June 19, 2022

Comments

  • highwaydog
    highwaydog about 2 years

    Hello since the last Xamarin update we get this error.

    CS0012 The type 'IJavaPeerable' is defined in an assembly that is not referenced. You must add a reference to assembly 'Java.Interop, Version=0.1.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'. ImageLibrary C:\Users\rutge\Source\Repos\GarderobeApp\ImageSwiper\ImageSwiper.cs 33 Active

    Does anybody have an idea what this means?

  • rideintothesun
    rideintothesun almost 8 years
    I still have this issue event when the Java.Interop has been added as a reference. Is there anything else I can try?
  • rideintothesun
    rideintothesun almost 8 years
    Forget that, my mistake, I had accidentally added the file to a PCL project rather than the Android one.
  • ToolmakerSteve
    ToolmakerSteve over 7 years
    Suppose you are building on a Mac?
  • DisplayName
    DisplayName over 6 years
    I do not have this subfolder under Microsoft\Framework\... Why is that?
  • btraas
    btraas over 5 years
    Thanks! All others didn't work for me (maybe it changed?). Worked after adding Mono.Android.Export.dll in MonoAndroid\2.3 folder.
  • Jaja Harris
    Jaja Harris over 4 years
    On Mac can find Java.Interop at following path: ‎⁨Macintosh HD⁩ ▸ ⁨Library⁩ ▸ ⁨Frameworks⁩ ▸ ⁨Xamarin.Android.framework⁩ ▸ ⁨Versions⁩ ▸ ⁨9.0.0-20⁩ ▸ ⁨lib⁩ ▸ ⁨xamarin.android⁩ ▸ ⁨xbuild-frameworks⁩ ▸ ⁨MonoAndroid⁩ ▸ ⁨v1.0⁩