Skip to content

F# support is broken in Xamarin.Android #12640

@Dolfik1

Description

@Dolfik1

Repro steps

Provide the steps required to reproduce the problem:

  1. Install Visual Studio or Visual Studio for Mac and enable both Xamarin and .NET Core support, these are listed as ‘Mobile development with .NET’ and ‘.NET Core Cross-platform development’ respectively.

  2. Open a command prompt window and install the template pack by entering:
    dotnet new -i Fabulous.XamarinForms.Templates

  3. Navigate to a folder in the command prompt window where your new app can be created and enter:
    dotnet new fabulous-xf-app -n SqueakyApp

  4. Build and run SqueakyApp.Android on device.

Expected behavior

The app build and run successfully

Actual behavior

/Users/nikolay/Dev/fsharp/SqueakyApp2/SqueakyApp2.Android/AssemblyInfo.fs(9,30): error FS0039: The type 'Android' is not defined.
/Users/nikolay/Dev/fsharp/SqueakyApp2/SqueakyApp2.Android/AssemblyInfo.fs(9,30): error FS0039: The type 'Android' is not defined.
/Users/nikolay/Dev/fsharp/SqueakyApp2/SqueakyApp2.Android/MainActivity.fs(20,63): error FS0039: The value, constructor, namespace or type 'Layout' is not defined.
/Users/nikolay/Dev/fsharp/SqueakyApp2/SqueakyApp2.Android/MainActivity.fs(21,61): error FS0039: The value, constructor, namespace or type 'Layout' is not defined.

These errors are due to Xamarin.Android.FSharp.ResourceProvider does not compile and does not load Resources library:
type Resources = SqueakyApp2.Android.Resource

Known workarounds

Use Paket instead of NuGet. Looks like Paket in a magical way works with this.
But Paket does not support MonoAndroid11 and MonoAndroid12 (link1, link2)

I also found out that there is no way to add back Xamarin.Android.FSharp.ResourceProvider 1.0.0.28 after remove:

Could not install package 'Xamarin.Android.FSharp.ResourceProvider 1.0.0.28'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v10.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

I tried to install Xamarin.Android.FSharp.ResourceProvider 1.0.1 and it is installed successfully but this version does not work (link1, link2) and I getting the same error as above with warning:

 Referenced assembly '/Users/nikolay/.nuget/packages/xamarin.android.fsharp.resourceprovider/1.0.1/lib/monoandroid81/Xamarin.Android.FSharp.ResourceProvider.Runtime.dll' has assembly level attribute 'Microsoft.FSharp.Core.CompilerServices.TypeProviderAssemblyAttribute' but no public type provider classes were found

Related information

Provide any related information (optional):

  • macOS 12.1
  • Xamarin.Android Version: 12.0.0.3 (Visual Studio Community)
  • Visual Studio Community 2019 for Mac Version 8.10.16 (build 2)

cc @dsyme @vzarytovskii @nosami

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions