Essentials: [Bug] Android 11 FileProvider runtime error

Created on 22 Sep 2020  路  11Comments  路  Source: xamarin/Essentials

Description

System.TypeLoadException: 'Could not load type 'Xamarin.Essentials.FileProvider' from assembly 'Xamarin.Essentials, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.'

Steps to Reproduce

  1. Create default XF Shell app
  2. Modify Target Framework to 11.0 and run application using Android R emulator
  3. 3.

Expected Behavior

No crash

Actual Behavior

System.TypeLoadException: 'Could not load type 'Xamarin.Essentials.FileProvider' from assembly 'Xamarin.Essentials, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.'

Basic Information

  • Version with issue: 1.5.3.2 and later
  • IDE: Visual Studio 16.8.0 Preview 3
  • Platform Target Frameworks:

    • iOS: not verified

    • Android: Android R

  • Android Support Library Version:
  • Nuget Packages:
<PackageReference Include="Plugin.CurrentActivity" Version="2.1.0.4" />
    <PackageReference Include="Microsoft.AppCenter.Analytics" Version="3.4.1" />
    <PackageReference Include="Microsoft.AppCenter.Crashes" Version="3.4.1" />
    <PackageReference Include="Xamarin.Forms" Version="4.8.0.1451" />
    <PackageReference Include="Xamarin.Essentials" Version="1.5.3.2" />
  • Affected Devices:

Screenshots


image

Reproduction Link

bug

All 11 comments

Running into this as well (though with Android 10/API 29 target). Is there a workaround? This means that any app that uses Xamarin.Essentials doesn't work on Android 11, no?

Your Compile and Target should always match. This is best practicej.

Are you using an API at all?

Following your steps it worked for me.

image

My Project
App22.zip

@jamesmontemagno I found that by adding this to csproj fixes the issue:

<AotAssemblies>false</AotAssemblies>
    <EnableLLVM>false</EnableLLVM>
    <AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
    <BundleAssemblies>false</BundleAssemblies>
**<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>**

It is the only difference between the template project and the one you attached

I had a chat with the Android team and the issue is that Android 11 decided not to work as it always has. As a result, the fastdev support is broken, right now, but is actually fixed again in an upcoming preview of VS 16.9 Preview 1. I am not sure of the timeline for that exactly, but for now you can disable the fastdev by adding <EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk> or unchecking the "Use Fast Deployment" box in VS:

image

I'm closing this for now as we have to wait for the VS update. And I believe the new VS also has a much better fast dev, so all good things coming soon.

@mattleibow when it is fixed, can I remove <EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>?

Yes. That is basically disabling fastdev. Very confusing name, but that is marketing vs engineering for you :) @dellis1972 Is the new fastdev going to be using the same element name in the csproj, or is this something fancy and new?

@mattleibow to keep things simple we are using the same element name EmbedAssembliesIntoApk .

Was this page helpful?
0 / 5 - 0 ratings