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

[MAUI] Update the bindings to work in .net 6+ (Maui) #11

Closed
AdamDiament opened this issue Oct 4, 2022 · 16 comments · Fixed by #36
Closed

[MAUI] Update the bindings to work in .net 6+ (Maui) #11

AdamDiament opened this issue Oct 4, 2022 · 16 comments · Fixed by #36
Labels
help wanted Extra attention is needed

Comments

@AdamDiament
Copy link
Collaborator

AdamDiament commented Oct 4, 2022

This might need to be a separate repo, as upgrading the target framework to add maui support will break Xamarin forms. I haven't decided what is best yet. Thoughts welcome, in particular PRs or ways to get XF-Maui side-by-side working.

Possible useful resources

https://learn.microsoft.com/en-us/events/dotnetconf-focus-on-maui/binding-native-libraries-for-dotnet-maui

@AdamDiament AdamDiament added the help wanted Extra attention is needed label Oct 4, 2022
@AdamDiament
Copy link
Collaborator Author

AdamDiament commented Oct 4, 2022

The first step will be to make sure all the referenced nuget dependencies support .net6 android/ios

I've had an initial audit, most do thankfully. There are two that don't:

  1. Xamarin.Google.Android.Material 1.3.1. Upgrading to 1.6.1 should provide a version that compiles for .net 6 - it might require adding a remove node like this but nothing major
   <remove-node path="/api/package[@name='com.zipow.videobox.viewmodel.phone']/class[@name='PhoneSettingCallForwardViewModel']"/>
  1. Com.Airbnb.Xamarin.Forms.Lottie 4.1.0 - there is an issue on the lottie repo requesting .net 6 support here if you want to bump it that would be helpful

@AdamDiament AdamDiament changed the title Update the bindings to work in .net MAUI Update the bindings to work in .net 6 for MAUI Oct 6, 2022
@AdamDiament
Copy link
Collaborator Author

I think we need to create an "Android Java Library Binding" for the jar to support MAUI droid. Does anyone know the build action needed for the aar? LibraryProjectZip is no longer available, which is the xamarin build action to be able to access both code and resources from the .aar.

@mdima
Copy link
Contributor

mdima commented Jul 13, 2023

Hi Adam,
I passed through this already for another project. You should set the Build Action to "AndroidLibrary" for the .aar files.

Have a good day,
Michele

@AdamDiament
Copy link
Collaborator Author

Hey @mdima, nice to hear from you! Thanks for the tip. I've renamed the repo now to a more generic dotnet name, and started the process of adding MAUI support in a separate sln.

For android, I have the aar loading now I've set it to the correct build configuration. I am working through some weird missing resource build failures. Have not started iOS yet. If you had any time to jump in and help with either, we'd love the support!

@AdamDiament AdamDiament changed the title Update the bindings to work in .net 6 for MAUI [MAUI] Update the bindings to work in .net 6+ (Maui) Jul 23, 2023
@AdamDiament
Copy link
Collaborator Author

AdamDiament commented Jul 24, 2023

The lib projects for android are both building now.

Trying to build the sample app for android, and getting this:

image

I remember dealing with similar issues during the Xamarin days. Not sure of the solution for MAUI. Adding the missing color resources in manually just throws up a whole bunch of new missing resource build errors.

I'm seeing if perhaps we are missing a required nuget package.

@AdamDiament
Copy link
Collaborator Author

AdamDiament commented Jul 24, 2023

Captain's log: star-date 24th July, Tellus

I added the nuget packages to match the xamarin version, and still get the same missing resource errors. I also added a version of the lottieMaui repo for android only. No dice.

As of right now, stuck!

@AdamDiament
Copy link
Collaborator Author

C.C @icalderond if you have any insight

@AdamDiament
Copy link
Collaborator Author

AdamDiament commented Jul 25, 2023

Ok with much back and forth I think that I have narrowed the problem down to these two nuget packages, neither of which support .net6+ yet. (Funnily enough they are by the same author, the awesome https://github.com/martijn00)

<PackageReference Include="Com.Airbnb.Xamarin.Forms.Lottie">
			<Version>4.1.0</Version>
</PackageReference>
<PackageReference Include="Xamarin.ExoPlayerSlim">
			<Version>2.16.1.12</Version>
</PackageReference>

ExoPlayer slim has plans to support Maui, I raised this issue here and they say it should be available soon. As an alternative, I tried using the full-fat exoplayer nuget, which does support .net6. It made me add a new remove node in the MetaData.xml but otherwise compiled. When referencing it via a .net maui project, I saw the missing resource errors. I don't yet know if that is because I added the full fat exoplayer, or if they are coming from missing Lottie stuff...

As for Lottie, there is a PR here to upgrade for net6 Baseflow/LottieXamarin#379 - apparently it works for droid but not for iOS yet. The PR has gone stale though and there is no sign of an upgrade. Perhaps someone with more iOS skills than me might consider jumping in.

A couple of possible hail-mary alternatives:

  • Skia Sharp has a nuget for lottie in pre-release. I wonder if this would add the necessary code to make the MAUI sample app compile. Seems unlikely but might be worth trying.
SkiaSharp.Skottie --version 2.88.3

When I add SkiaLottie the resource errors go away (or get hidden) but I get these errors

image

I might be able to shim these, will try tomorrow...

Tried the shim. These two resource errors went away, but then all the original resource errors reappeared. My current working theory is that they are caused by a dependency in exoplayer full-fat. So I'm going to wait for the slim binding to be available and try again. If after putting that back in, we still get resource errors, they must be because of Lottie.

@AdamDiament
Copy link
Collaborator Author

AdamDiament commented Jul 26, 2023

The missing resources are all defined in ZoomCommonLib. I'm wondering if there is an issue with how maui handles one binding library that references another. (HeadProject => MobileRTC => ZoomCommonLib)

Adding all the resources from zoomcommon lib manually into my maui android resources, just throws up more missing resource errors though. Mainly from exoplayer... I'm using the full fat library. Maybe I need to look at its dependencies and manually include them

.... nope, not that!

@AdamDiament AdamDiament mentioned this issue Aug 8, 2023
@samirgcofficial
Copy link

samirgcofficial commented Sep 2, 2023

Any updates for the .net maui support?

@AdamDiament
Copy link
Collaborator Author

No, I am still working through the issues as described in the comments

@AdamDiament
Copy link
Collaborator Author

AdamDiament commented Sep 11, 2023

An update, although without good news, is that on the MAUIFY branch I used the full fat exoplayer, and a version of lottie that compiled for .net 7, which I hoped would clear up the remaining issues. Yet I still get the exact same errors, so either one of those packages is causing problems, or another package is the problem, or there is a deeper problem with MAUI bindings that I don't understand. If anyone has any wisdom to share, I am all ears! I wish the error messages were more informative - I am certain that the actual error is nothing to do with missing resources, rather that the compile step fails for the actual reason before the resources can be included, and the real error is swallowed somewhere.

@AdamDiament
Copy link
Collaborator Author

After much much much trial and error and a big dose of help from @timjamwoo I got a zoom call working on MAUI Android! Stay tuned for a PR and a nuget package.

iOS support will come soon too hopefully.

@AdamDiament
Copy link
Collaborator Author

AdamDiament commented Sep 18, 2023

@timjamwoo when doing this for iOS, you have two options. 1) copying the current project from XF over into the maui sln and porting the csproj file to .net 7, or 2) creating a new project from scratch. If you choose option 2, the top one in the screenshot is the project type you need

image

Here are some instructions for the porting option, which will also be useful if you start from scratch as it contains details of breaking changes between xf and iOS you'd have to deal with either way.

dotnet/docs-maui#1514

For Android I used the new project template, but I'm sure either would work fine.

@AdamDiament
Copy link
Collaborator Author

AdamDiament commented Sep 18, 2023

@timjamwoo

Required iOS tasks

  • Port or create new iOS binding project inside the MAUI sln
  • Update the sample app to target iOS too (change targeted projects in csproj file, add platforms folder with relevant appdelegate.cs files etc)
  • Implement any needed platform specific iOS zoom services in the sample app
  • Confirm you can launch a zoom call in default ui on the sample app
  • Create a nuget package from the iOS lib and test it via a local nuget feed in the MAUI branch of iOS on Visual Service main project (We might need to reimplement the non mock zoom .sln for MAUI before doing this part)
  • @AdamDiament Upload it to nuget.org with the Visual Service account
  • @timjamwoo link to the online nuget package itself

@AdamDiament
Copy link
Collaborator Author

@AdamDiament remaining Android Tasks

  • Build the nuget package for Android
  • Test it locally via local nuget feed in the main visual service MAUI sln (We might need to reimplement the non mock zoom .sln for MAUI before doing this part)
  • Upload it to nuget.org
  • Link to the online version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants