TimLariviere / Fabulous-new

Fabulous v2 - Work in progress
https://timothelariviere.com/Fabulous-new/
Other
41 stars 3 forks source link

🎁 Fix Samples #6

Closed heytherewill closed 2 years ago

heytherewill commented 2 years ago

This PR fixes the loading and compilation of the Android samples

There apparently is also a runtime error when you run the Android Samples, but it's one of those inflate errors that is usually a result of stale bin/obj (amazing how we are still getting the same errors in Xamarin since I started using it in 2014).

Since I have no way of knowing if it's an actual error or not, I'd kindly ask the maintainers to test this locally and, if there indeed is a runtime error, let me know so I can pinpoint it and fix it :)

TimLariviere commented 2 years ago

Thanks!

Took a look at the inflate error, but it's not coming from Fabulous.

I created an empty F# Android project with VS 2022 (macOS & Windows), it works correctly. So I added XF and modified the MainActivity to use it.

But when I make MainActivity inherit from FormsAppCompatActivity, there's an inflate error. When I inherit from FormsApplicationActivity, it works.

TimLariviere commented 2 years ago

Also tried to use Xamarin.Android.FSharp.ResourceProvider 1.0.1, but it's definitely not working. https://github.com/xamarin/Xamarin.Android.FSharp.ResourceProvider/issues/9

So I downgraded to 1.0.0.28 to resolve the resources correctly.

heytherewill commented 2 years ago

I'm marking this one as ready for review, then, given that the error is outside of the scope of Fabulous :)

TimLariviere commented 2 years ago

@heytherewill Sorry, by this I meant that the error was not caused by Fabulous, but not that we can't do anything about it.

We still need to figure out if we're doing something wrong with the default Xamarin.Forms template or if there's really a bug on the Android/Xamarin.Forms side. Because currently the Android samples are useless.

Ideally, we should be doing the same than the default Xamarin.Forms Android template. Meaning, using FormsAppCompatActivity and Xamarin.Android.FSharp.ResourceProvider.

The best way to check is to create a separate C# Xamarin.Forms blank project and see what they're doing to get the Android app to work.

And if in the end we're still facing a bug, we need to open an issue on https://github.com/xamarin/xamarin-android

heytherewill commented 2 years ago

After a lot of investigation, I can't seem to find anything relevant here:

After a lot of fiddling with the fsproj, I managed to change the error from an Inflate exception to 'Unable to convert instance of type 'AndroidX.AppCompat.Widget.AppCompatCheckedTextView' to type 'AndroidX.AppCompat.Widget.Toolbar'.'. This seems related to the AppCompatActivity.ToolbarResource field, but I'm not sure why this wouldn't work out of the box. I've tested with using our own toolbar resource, but that was to no avail as well.

I'm dumping my findings here in order to have them documented somewhere to avoid work duplication, but there's a couple more things I'd like to try, like completely nuke the existing fsproj and create a new one from scratch. Maybe that'll work.

TimLariviere commented 2 years ago

Superseded by #44