C# Xamarin Java.Interop 错误?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37788326/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
C# Xamarin Java.Interop error?
提问by highwaydog
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. 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
CS0012 类型“IJavaPeerable”是在未引用的程序集中定义的。您必须添加对程序集“Java.Interop, Version=0.1.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065”的引用。ImageLibrary C:\Users\rutge\Source\Repos\GarderobeApp\ImageSwiper\ImageSwiper.cs 33 活动
Does anybody have an idea what this means?
有人知道这是什么意思吗?
回答by neneo
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 :
然后 :
- Go to your Android project
- Right Click in reference and choose "Add Reference"
- Browse file location
- Add and done
- 转到您的 Android 项目
- 右键单击引用并选择“添加引用”
- 浏览文件位置
- 添加并完成
if you still get error, try to rebuild your project
如果您仍然遇到错误,请尝试重建您的项目
回答by OrcusZ
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 的引用即可解决问题。
- Go to your Android project
- Right Click in reference and choose "Add Reference"
- On Assembly, look for Java.Interop and add it
- Rebuild your project
- 转到您的 Android 项目
- 右键单击引用并选择“添加引用”
- 在 Assembly 上,查找 Java.Interop 并添加它
- 重建你的项目
If you need some screenshots, I can provide them later.
如果您需要一些屏幕截图,我可以稍后提供。
回答by Rohan Sampat
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 Studio17\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid
This might be the case with someone else.
这可能是其他人的情况。
回答by wonea
You can hover over the offending line and see the missing DLL.
您可以将鼠标悬停在违规行上并查看丢失的 DLL。
Now add the missing reference;
现在添加缺少的参考;
Open the Solution Explorer, and within References right click, and select Add Reference
Within the Reference Manager click Browse, and Browse again.
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\
Click Java.Interop.dll
单击 Java.Interop.dll
- Okay the Reference Manager
- 好的,参考经理
回答by Arun Prasad
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.
您可以直接将程序集Java.Interop.dll
从复制C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0
到bin/Debug
项目的文件夹中以解决该问题。
This procedure perfectly worked for me.
这个程序对我来说非常有效。
Thanks,
谢谢,
回答by Dave Rincon
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
那是我的解决方案,现在我的两个应用程序工作
回答by Jammer
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
. At least this is correct in my case, my solution still compiles and functions without manually referencing any Reference Assemblies.
这些错误不是由解决方案或参考资料的问题引起的。它们是其他更改的副产品,这些更改似乎混淆了诸如ReSharper
. 至少在我的情况下这是正确的,我的解决方案仍然可以编译和运行,而无需手动引用任何参考程序集。
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.
然后忽略这里的问题。