Java安卓到Xamarin的C#android [英] Java android to C# android in Xamarin

查看:217
本文介绍了Java安卓到Xamarin的C#android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些我在eclipse中导出为.jar文件的java类。此外,我在Xamarin中创建了一个java绑定库项目,并将.jar文件添加到jar文件夹中。我需要在xamarin中创建另一个Android应用程序项目并将库项目引入其中并将该库用于android应用程序项目中的类。



我需要知道是否这是将eclipse上的android项目转换为c#android的正确方法xamarin

I have certain java classes which i have exported as a .jar file in eclipse. Further, I have created a java binding library project in Xamarin and added the .jar file to the jar folder. I need to create another android app project in xamarin and reference the library project into it and use the library into classes in the android app project.

I need to know whether is this the right way to convert an android project on eclipse into c# android in xamarin

推荐答案

你不能直接从.NET Framework引用Java类,但是你可以从.NET应用程序运行Java代码。



您可以使用名为IVKM.Net的工具执行此操作。 IVKM.NET包含一个名为ikvmc的应用程序。您可以在此处查看文档 http://www.ikvm.net/userguide/ikvmc.html [ ^ ]



使用它将你的java代码编译成Jar文件。



然后运行ikvmc程序:



ikvmc myJavaCode.jar



如果jar代码包含main()入口函数,那么它将被转换为EXE而不是执行并运行CLR。如果没有,那么它将被转换为DLL。这些DLL可以通常的方式作为引用添加到Visual Studio项目中。
You can't directly reference Java classes from the .NET Framework, but you can run Java code from a .NET application.

You do it using a tool called IVKM.Net. IVKM.NET includes an application called ikvmc. You can view the documentation for it here http://www.ikvm.net/userguide/ikvmc.html[^]

To use it compile your java code into a Jar file.

Then run the ikvmc program:

ikvmc myJavaCode.jar

If you jar code contains a main() entry function then it will be converted into an EXE than be executed and run on the CLR. If it doesn't then it will be converted into DLL's. These DLL's can be added to your Visual Studio project as References in the usual manner.






不可能在Xamarin IDE中将Java隐藏到Xamarin ..



http://developer.xamarin.com/guides/android/advanced_topics/java_integration_overview/ [ ^ ]



需要使用一些转换工具并确保每个类,方法,属性,接口等遵循命名约束...



http://developer.xamarin.com/guides/android/advanced_topics/java_integration_overview/porting_java_to_csharp/ [ ^ ]



您也可以直接在Xamarin中使用Java代码并调用JNI



请参阅以下链接中的源代码



http://developer.xamarin.com/samples/JniDemo/ [ ^ ]



谢谢,



Ullas krishnan
Hi,

Its not possible to covert Java to Xamarin in Xamarin IDE..

http://developer.xamarin.com/guides/android/advanced_topics/java_integration_overview/[^]

Need to use some converter tool and also make sure that every class, methods, properties, interface etc follow the naming constraints...

http://developer.xamarin.com/guides/android/advanced_topics/java_integration_overview/porting_java_to_csharp/[^]

You can also use Java Code directly in Xamarin and invoking the JNI

See source code from the below link

http://developer.xamarin.com/samples/JniDemo/[^]

Thanks,

Ullas krishnan


这篇关于Java安卓到Xamarin的C#android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆