Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with Template #69

Open
guipalazzo opened this issue Jan 7, 2025 · 8 comments
Open

Issues with Template #69

guipalazzo opened this issue Jan 7, 2025 · 8 comments

Comments

@guipalazzo
Copy link

Description

The template, as is, does not seem to be working. The using directives are not being recognized, apparently due to the declaration of Metadata.xml.

I tried many different approaches to fix this (mostly by trying to add the generated *. aar file somehow to the project, for instance, as an AndroidLibrary or as an EmbeddedReferenceJar), but I'm getting to the conclusion that the original intention was to have something behind the scenes that would make the conversion specified in the Metadata.xml implementation work.

As per the content generated about the template, I was expecting that a simple build in Android Studio would be enough to make it happen. Before trying to fix this as I mentioned above, I was expecting that a simple build of the native Android project, followed by the build of the .Net Maui project, would be enough, as per the high level discussion on this between @rachelkang and @jamesmontemagno.

Steps to Reproduce

  1. Clone the repository
  2. Open the template solution as is
  3. Build the android native project
  4. Build the .Net Maui
  5. See that the Android using directives are not working;

Link to public reproduction project repository

No response

Environment

  • OS:
  • .NET MAUI:
  • Target platforms:
@rachelkang rachelkang added needs info Requires more information from issue reporter needs reproduction labels Jan 13, 2025
@rachelkang
Copy link
Collaborator

Hi @guipalazzo - Could you please elaborate on how the using directives are not being recognized? Are you running into specific build errors? If so, could you please share a binlog?

@guipalazzo
Copy link
Author

Hello @rachelkang,

When you open the template on your end, does it work out of the box? When I do so on my end, I see a 'Cannot resolve symbol 'NewBindingMaciOS' related to the using directives of 'MauiPage.xaml.cs'. I was expecting it though, as I'm using a PC.

#if IOS || MACCATALYST using NewBinding = NewBindingMaciOS.DotnetNewBinding; #elif ANDROID using NewBinding = NewBindingAndroid.DotnetNewBinding; #elif (NETSTANDARD || !PLATFORM) || (NET6_0_OR_GREATER && !IOS && !ANDROID) using NewBinding = System.Object; #endif

However, even if I remove the iOS, MacOS and PC related directives, as follows, I'm still not able to use 'NewBinding'.

#if ANDROID using NewBinding = NewBindingAndroid.DotnetNewBinding; #endif

So, the question would be, what are the necessary steps in order to make this work? I tried to compile the native project in Android Studio, but nothing happens, so I'm not sure how to make this slim bindings work at all.

@dotnet-policy-service dotnet-policy-service bot removed needs info Requires more information from issue reporter needs reproduction labels Jan 13, 2025
@guipalazzo
Copy link
Author

Hello @rachelkang,

When you open the template on your end, does it work out of the box? When I do so on my end, I see a 'Cannot resolve symbol 'NewBindingMaciOS' related to the using directives of 'MauiPage.xaml.cs'. I was expecting it though, as I'm using a PC.

#if IOS || MACCATALYST using NewBinding = NewBindingMaciOS.DotnetNewBinding; #elif ANDROID using NewBinding = NewBindingAndroid.DotnetNewBinding; #elif (NETSTANDARD || !PLATFORM) || (NET6_0_OR_GREATER && !IOS && !ANDROID) using NewBinding = System.Object; #endif

However, even if I remove the iOS, MacOS and PC related directives, as follows, I'm still not able to use 'NewBinding'.

#if ANDROID using NewBinding = NewBindingAndroid.DotnetNewBinding; #endif

So, the question would be, what are the necessary steps in order to make this work? I tried to compile the native project in Android Studio, but nothing happens, so I'm not sure how to make this slim bindings work at all.

@007vel
Copy link

007vel commented Feb 11, 2025

@rachelkang I am Facing the same issue, unable to run the samples
Native android build -SUCCESSFUL
NativeBinding build- SUCCESSFUL

but unable to reference the native classes in Maui project

Image

@JacobRustyDev
Copy link

I'm also experiencing this issue. The fact that this isn't incredibly common leads me to believe its something wrong with my dev environment but I have no way of know what is wrong. Are there details I can post that would help?

@MouratidisA
Copy link

I'm also facing the same issue!
I tested the official template project without making any modifications, and while both native apps build without any errors and both binding projects compile successfully, the MauiSample fails with the following errors:

  • Cannot resolve symbol 'NewBindingAndroid'
  • Cannot resolve symbol 'GetString'

Has anyone found a solution? Any insights would be greatly appreciated!

@Dicusar94
Copy link

I am also facing this issue, how to fix it ?

@MouratidisA
Copy link

MouratidisA commented Mar 9, 2025

I am also facing this issue, how to fix it ?

I've tried to add the released .dll from the native project on the maui project and the template worked!
On the MauiSample.csproj add the following:
<ItemGroup> <Reference Include="NewBinding.Android.Binding"> <HintPath>..\android\NewBinding.Android.Binding\bin\Release\net9.0-android\NewBinding.Android.Binding.dll</HintPath> </Reference> </ItemGroup>
Currently I cannot make my own methods be visible from the maui project, any help or sample will be extremely appreciated! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants