0

This is kind of a general question but anyway: In c# I have made a class library(api) which works on windows systems. I am now looking into making an api with the same functionalityies for android. One of the functionalityes (streming data from custom bluetuth device) needs to be written in java. So (in android studio) I have written a java class to do that, compiled a .jar and tested it in Unity as a plugin. But to avoid translating a ton of c# code into java I am now wondering if it is possible to somehow import a c# api into android studio and just call it's methods from java classes( as you can do in Unity's.Monobehaviour (AndroidJavaClass.Call("functionName", object[]parameters)) or maybe as you can do wit .jar-s code in VisualStudio(IVKM.Net. IVKM.NET))? To put it as plainly as possible: I would like to convert a api.dll to api.jar.

If you can suggest another alternative solution, please do so. Thanks.

jib fashr
  • 315
  • 2
  • 15
  • Android does not have builtin C# runtime. See [this](https://stackoverflow.com/questions/27633893/how-to-execute-c-sharp-code-at-runtime-in-xamarin-android), and maybe also [this](https://learn.microsoft.com/ru-ru/xamarin/android/internals/limitations) – M. Prokhorov Apr 11 '18 at 10:13

1 Answers1

0

Havent tried, but will try hinting towards C++ support in Android with Native development Kit by converting C# to C++ code, as in .net all of your code is CLI code anyways, so it should be convertible to some barely readable C++ surogate code which should compile just fine.

https://www.quora.com/Can-we-use-C++-and-Java-together-in-Android-Studio

Hope this helps!

Dave Anders
  • 799
  • 6
  • 13
  • This could be used for converting C# to C++, to get it into NGK https://www.tangiblesoftwaresolutions.com/product_details/csharp_to_cplusplus_converter_details.html – Dave Anders Apr 11 '18 at 10:23
  • Yes, but as it says in the post on the link https://www.quora.com/Can-we-use-C++-and-Java-together-in-Android-Studio, there is no guarantie that the translated code will work on all android device processors. The idea behnd my api is axactly the oposite. It should work with all devices and be as universal as possible. Aldo your answer is ok I am still looking for a way to aut-convert c# into java. – jib fashr Apr 11 '18 at 11:47