How do you call a native Android library (Java/Kotlin) from MAUI?
Short answer
Use a .NET for Android binding library that projects the Java/Kotlin AAR or JAR into C# through a bindings project, then reference it from Platforms/Android code. Microsoft provides binding tooling and metadata transforms to fix API surface issues.
Advertisement
AModel answer
Use a .NET for Android binding library that projects the Java/Kotlin AAR or JAR into C# through a bindings project, then reference it from Platforms/Android code. Microsoft provides binding tooling and metadata transforms to fix API surface issues.
// In an Android bindings project, reference the .aar,
// then call the generated C# API from Platforms/Android.
var client = new Com.Vendor.Sdk.Client(context);Real-world example
A payment SDK shipped only as an Android AAR is consumed by generating a C# binding and calling it from Android-specific code.
Likely follow-ups
- What is a bindings project? | How do you fix a broken generated API?
Related topics