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.
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.
As Bohdan said, it is same as Xamarin.Forms. We need to create Multiple projects to manage this projects. The architecture, we follow is below.
- .NET Maui Class Library
- Maui Droid Projects (Holding Android Jar files)
- Maui iOS Projects (Holding iOS Jar files)
Like below image and go through the below repo, this might help you.
https://github.com/CommunityToolkit/Maui.NativeLibraryInterop
Video Tutorial - https://learn.microsoft.com/en-us/shows/dotnetconf-focus-on-maui/binding-native-libraries-for-dotnet-maui
Guide for iOS - https://learn.microsoft.com/en-us/dotnet/maui/migration/ios-binding-projects?view=net-maui-8.0
Guide for Android - https://learn.microsoft.com/en-us/dotnet/maui/migration/android-binding-projects?view=net-maui-8.0
I wrote a blog for android binding few days ago, this might help you - https://xmonkeys360.com/2024/05/08/binding-android-kotlin-libraries-for-net-maui/
© 2022 - 2025 — McMap. All rights reserved.