'A very complicated workaround for using a C# dll with an Android app? (xamarin)

I have an proprietary Android app (created with Android Studio) and I need to add some functionality which requires to use a C# DLL.

The app is connecting wirelessly to a development board that does some sensor measurements. Normally on windows apps the dll is used to do some complex calculations of calibration coefficients for the measuring.

My problem is:

  1. I don't have the the source code of the DLL and most likely I won't be approved to access it.
  2. I've read that you can use xamarin to make android apps and use C# dlls but I can't rewrite the whole app for xamarin just to use the dll (also I've never used xamarin)

So far I had the idea to build a simple http server with C# that gets parameters with a GET request, runs them through the dll and returns the results. However it's not an ideal solution because it requires a separate pc to run the server and the adndroid device to have a network connection to it.

My second idea is to build a separate app with xamarin that uses the dll and make my main app start it just to calculate the coefficients and get the results. Perhaps make the second app not visible in the launcher and somehow distribute the two apps together.

Since I am not experienced with android development and especially xamarin and I don't have a lot of time to waste on this project I want to know if my idea is feasible or if there is a better alternative.

Can you suggest some useful tutorials for xamarin and using dlls with it?

===============================================

Edit

I have managed to get the source code of the dll project which is in C++ (and full of windows only stuff) and now I'm trying to use NDK to compile it and JNI with Android studio to use the native functions. Unfortunately almost every step has it's own quirks and problems and it's far from smooth :/ I wouldn't recommend it to beginners like me!



Solution 1:[1]

I know this answer is late, but I'm in a similar situation right now.

This project here helped me setup a native Android Studio build with an embedded C# lib: https://github.com/royd/KotlinAppWithXamarinDependency

The only issue I'm facing right now, that I can't get the R8 obfuscation/optimization to work without breaking the app.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Stoberdo