Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create bindings to native libraries .net Maui

Is there any way to bind native libraries like in Xamarin? I have tried to do some native implementations in the new .NET Maui and haven't had success on it. I would really appreciate if someone has some information about it.

like image 516
jaesjulio Avatar asked Jan 19 '26 14:01

jaesjulio


2 Answers

Yes, native library bindings are done the same way as in Xamarin, there are two new project templates "Android Java Library Binding" and "iOS Binding Library" just add them and follow regular Xamarin documentation in order to configure it:

  • https://learn.microsoft.com/en-us/xamarin/ios/platform/binding-objective-c/
  • https://learn.microsoft.com/en-us/xamarin/android/platform/binding-java-library/

For android you can also check this git repo - https://github.com/Bohdandn/MAUI.WebRTC.Demo, unfortunately iOS doesn't compile there.

like image 162
Bohdan Avatar answered Jan 21 '26 05:01

Bohdan


For android jar files, I'm using .NET MAUI class library enter image description here

<ItemGroup Condition="$(TargetFramework.Contains('-android'))">
    <EmbeddedJar Include="classes.jar" />
</ItemGroup>

Add this "ItemGroup" to your project, if you can create a wrap class like

enter image description here

like image 20
AntonioHL Avatar answered Jan 21 '26 05:01

AntonioHL



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!