A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
Hello @mc ,
Thanks for your question.
Yes, you can use native C++ libraries in both .NET MAUI and .NET Android. Unfortunately, System.Device.Gpio is not supported on Android. It is designed specifically for Linux-based IoT platforms.
I recommend calling native C++ via P/Invoke:
- Compile your C++ code as a shared library (.so file) for ARM64.
- Place the
.soin your project underlib/arm64-v8a/. - Call it directly from C#:
using System.Runtime.InteropServices;
public static class GpioInterop
{
private const string LibName = "libgpio_rk3568";
[DllImport(LibName)]
public static extern int gpio_export(int pin);
[DllImport(LibName)]
public static extern int gpio_set_direction(int pin, int direction);
[DllImport(LibName)]
public static extern int gpio_write(int pin, int value);
}
I hope this addresses your question. If this response was helpful, please consider following the guidance to provide feedback.