简体   繁体   English

C# Xamarin Java.Interop 错误?

[英]C# Xamarin Java.Interop error?

Hello since the last Xamarin update we get this error .您好,自上次Xamarin update以来,我们收到此error

CS0012 The type 'IJavaPeerable' is defined in an assembly that is not referenced. CS0012 类型“IJavaPeerable”是在未引用的程序集中定义的。 You must add a reference to assembly 'Java.Interop, Version=0.1.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'.您必须添加对程序集“Java.Interop, Version=0.1.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065”的引用。 ImageLibrary C:\\Users\\rutge\\Source\\Repos\\GarderobeApp\\ImageSwiper\\ImageSwiper.cs 33 Active ImageLibrary C:\\Users\\rutge\\Source\\Repos\\GarderobeApp\\ImageSwiper\\ImageSwiper.cs 33 活动

Does anybody have an idea what this means?有人知道这是什么意思吗?

You can found it here你可以在这里找到

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

then :然后:

  1. Go to your Android project转到您的 Android 项目
  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如果您仍然遇到错误,请尝试重建您的项目

I go the same error after the last update.我在上次更新后出现同样的错误。 You just have to add the reference to Java.Interop to resolve the problem.您只需添加对 Java.Interop 的引用即可解决问题。

  1. Go to your Android project转到您的 Android 项目
  2. Right Click in reference and choose "Add Reference"右键单击引用并选择“添加引用”
  3. On Assembly, look for Java.Interop and add it在 Assembly 上,查找 Java.Interop 并添加它
  4. Rebuild your project重建你的项目

If you need some screenshots, I can provide them later.如果您需要一些屏幕截图,我可以稍后提供。

In my case it was a bit different, I couldn't find monoandroid folder in就我而言,它有点不同,我找不到 monoandroid 文件夹

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.这可能是其他人的情况。

You can hover over the offending line and see the missing DLL.您可以将鼠标悬停在违规行上并查看丢失的 DLL。

线路抱怨缺少参考

Now add the missing reference;现在添加缺少的参考;

  1. Open the Solution Explorer, and within References right click, and select Add Reference打开解决方案资源管理器,在引用中右键单击,然后选择添加引用从解决方案资源管理器添加引用

  2. Within the Reference Manager click Browse, and Browse again.在参考管理器中单击浏览,然后再次浏览。 添加参考

  3. In the file dialog copy and paste this path:在文件对话框中复制并粘贴此路径:

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

转到DLL路径

Click Java.Interop.dll单击 Java.Interop.dll

添加文件

  1. Okay the Reference Manager好的,参考经理

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.您可以直接将C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\MonoAndroid\\v1.0中的C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\MonoAndroid\\v1.0Java.Interop.dll复制到项目的bin/Debug文件夹中以解决该问题。

This procedure perfectly worked for me.这个程序对我来说非常有效。

Thanks,谢谢,

These errors are not due to a problem with the solution or the references.这些错误不是由解决方案或参考资料的问题引起的。 They are a by-product of other changes that seem to confuse tools like ReSharper .它们是其他更改的副产品,这些更改似乎混淆了ReSharper等工具。 At least this is correct in my case, my solution still compiles and functions without manually referencing any Reference Assemblies.至少在我的情况下这是正确的,我的解决方案仍然可以编译和运行,而无需手动引用任何参考程序集。

There is a Xamarin bug report for this but they determined this to be an external issue with ReSharper as per my experience.有一个 Xamarin 错误报告,但根据我的经验,他们确定这是ReSharper的外部问题。

Rather than manually adding references to the project you can also tell ReSharper to simply ignore the errors by opening:除了手动添加对项目的引用之外,您还可以通过打开以下命令告诉 ReSharper 简单地忽略错误:

ReSharper -> Windows -> Solution Errors

And then ignoring the issues here.然后忽略这里的问题。

In my case iOS and Android use the seem Business Layer when I run my android application works ok but when I run iOS show me the error You must add a reference to assembly 'Java.Interop, Version=0.1.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'在我的情况下,当我运行我的 android 应用程序时,iOS 和 Android 使用似乎业务层,但是当我运行 iOS 时,向我显示错误您必须添加对程序集'Java.Interop,版本 = 0.1.0.0,文化 = 中性的引用, PublicKeyToken=84e04ff9cfb79065'

The problem: I was using JSONObject from Org.Json问题:我使用的是 Org.Json 的 JSONObject

https://docs.microsoft.com/en-us/dotnet/api/org.json.jsonobject?view=xamarin-android-sdk-9 https://docs.microsoft.com/en-us/dotnet/api/org.json.jsonobject?view=xamarin-android-sdk-9

this dll just work with android这个 dll 只适用于 android

I need change for JsonObject from System.Json我需要从 System.Json 更改 JsonObject

https://docs.microsoft.com/en-us/dotnet/api/system.json.jsonobject?view=dotnet-plat-ext-2.1 https://docs.microsoft.com/en-us/dotnet/api/system.json.jsonobject?view=dotnet-plat-ext-2.1

That was my solution, now my two applications work那是我的解决方案,现在我的两个应用程序工作

如果您仍然找不到 Java.Interop,请在 C: 驱动器内的搜索栏中搜索“Java.Interop”并将其添加为对您项目的引用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM