Skip to content
This repository has been archived by the owner on Apr 2, 2022. It is now read-only.

🎁 Fix Samples #6

Closed
wants to merge 6 commits into from
Closed

🎁 Fix Samples #6

wants to merge 6 commits into from

Conversation

heytherewill
Copy link

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
Copy link
Owner

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
Copy link
Owner

Also tried to use Xamarin.Android.FSharp.ResourceProvider 1.0.1, but it's definitely not working.
xamarin/Xamarin.Android.FSharp.ResourceProvider#9

So I downgraded to 1.0.0.28 to resolve the resources correctly.

@heytherewill heytherewill marked this pull request as ready for review November 19, 2021 17:19
@heytherewill
Copy link
Author

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

@TimLariviere
Copy link
Owner

@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
Copy link
Author

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

  • I've created a new Xamarin.Forms project and we are pretty much doing things line by line
  • I tried copying everything (from Manifest entries to every single configuration) but to no avail

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.

@edgarfgp edgarfgp mentioned this pull request Jan 14, 2022
@TimLariviere
Copy link
Owner

Superseded by #44

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

Successfully merging this pull request may close these issues.

2 participants