CommunityToolkit / Maui.NativeLibraryInterop

Maui.NativeLibraryInterop is a community-created library of binding samples to help .NET MAUI developers interop with native libraries more easily
MIT License
181 stars 28 forks source link

I don't know how to use it? #52

Open honeyhead opened 1 month ago

honeyhead commented 1 month ago

Description

I opened the project in Android Studio, navigated to the Native folder, built the Gradle project, and confirmed that the .aar file was generated with the latest timestamp. I then opened the Sample project, which refers to the NewBinding.Android.Binding project.

`

false false

` The issue is with the following line:

`#if ANDROID using NewBinding = NewBindingAndroid.DotnetNewBinding;

endif

`

I can't find NewBindingAndroid.DotnetNewBinding.

It would be great if you could provide a "step-by-step" explanation, as I'm having a hard time understanding anything outside of MAUI.

How can I use this correctly?

Also, I have another question:

Assuming you are able to get this working, would it be possible to use this method to switch activities from pop-ups or other windows when implementing SDKs used for marketing tools?

Steps to Reproduce

I wrote it in the description

Link to public reproduction project repository

No response

Environment

rachelkang commented 1 month ago

Hi, @honeyhead - Thank you for checking out Native Library Interop! If you haven't already, I highly recommend checking out the documentation at https://learn.microsoft.com/dotnet/communitytoolkit/maui/native-library-interop/get-started which may include some of the explanations you are looking for. If there is anything additional you wish the documentation would cover, please let us know.

As per the docs, NewBindingAndroid.DotnetNewBinding is located at https://github.com/CommunityToolkit/Maui.NativeLibraryInterop/blob/main/template/android/native/newbinding/src/main/java/com/example/newbinding/DotnetNewBinding.java

HomeroLara commented 1 month ago

Hi @rachelkang thanks for the samples you've put together. I have a question, specifically about the Facebook Sample project. For Android, why are the Android native SDKs referenced in the Sample.csproj file ( see here )? Wouldn't the native project, which is being used to create the MAUI Binding library have those SDKs already?

Thanks again!

rachelkang commented 1 month ago

Hi, @HomeroLara - great question! The gradle/maven dependencies often need to be explicitly referenced, as they are not automatically bundled into the library. The build.gradle.kts file is currently configured to copy dependencies into a bin/outputs/deps folder that can then be referenced in the sample.

As per the comment in that Sample.csproj file you linked, this will hopefully be further streamlined, and we will update the docs when that time comes. @pjcollins can add more context if you have more questions :)

HomeroLara commented 1 month ago

Hi, @HomeroLara - great question! The gradle/maven dependencies often need to be explicitly referenced, as they are not automatically bundled into the library. The build.gradle.kts file is currently configured to copy dependencies into a bin/outputs/deps folder that can then be referenced in the sample.

As per the comment in that Sample.csproj file you linked, this will hopefully be further streamlined, and we will update the docs when that time comes. @pjcollins can add more context if you have more questions :)

Thanks for the response @rachelkang. This gives me an idea: I think I can modify the build.gradle file from my Kotlin project to embed the needed .aar files into one.