[Bug] [Android] System.IO.FileNotFoundException when <BundleAssemblies>True</BundleAssemblies>
See original GitHub issueDescription
After upgrade from Xamarin.Forms 4.4.0.991640 to 4.5.282-pre4 I noticed that when
<BundleAssemblies>True</BundleAssemblies>
app crash on start with exception
System.IO.FileNotFoundException: Could not load file or assembly ‘Xamarin.AndroidX.AppCompat.Resources, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’ or one of its dependencies.
My working setup for release in 4.4 is
<AndroidLinkMode>Full</AndroidLinkMode>
<AotAssemblies>True</AotAssemblies>
<AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
<EnableLLVM>True</EnableLLVM>
<BundleAssemblies>True</BundleAssemblies>
in 4.5 everything works fine only if
<AndroidLinkMode>Full</AndroidLinkMode>
<AotAssemblies>True</AotAssemblies>
<AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
<EnableLLVM>True</EnableLLVM>
<BundleAssemblies>False</BundleAssemblies>
Steps to Reproduce
- Create new solution
- Upgrade Xamarin to 4.5.0.282-pre4
- Set:
<AndroidLinkMode>Full</AndroidLinkMode>
<AotAssemblies>True</AotAssemblies>
<AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
<EnableLLVM>True</EnableLLVM>
<BundleAssemblies>True</BundleAssemblies>
- Run app on the real device
Expected Behavior
App starts.
Actual Behavior
App crash with System.IO.FileNotFoundException exception.
Basic Information
- Version with issue: 4.5.0.282-pre4
- Last known good version: 4.4.0.991640
- IDE: Visual Studio 2019
- Platform Target Frameworks:
- Android: Xamarin.Android 10.1
- Android Support Library Version: 28.0.0.03, AndroidX 1.1.0
- Nuget Packages:
- Affected Devices: all
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:82 (30 by maintainers)
Top Results From Across the Web
System.IO.FileNotFoundException error to build Android ...
Error : Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'Xamarin.iOS, Version=0.0.0.0, Culture: ...
Read more >Debugging System.IO.FileNotFoundException - Cause and fix
The typical cause of this error is that the referenced assembly isn't on the file system. There can be multiple causes of this....
Read more >system.IO.FileNotFoundException error when I open the . ...
I got a software which can be installed through Clickonce application deployment support library and can be started through .exe file.
Read more >FileNotFoundException Class (System.IO)
Initializes a new instance of the FileNotFoundException class with a specified error message, and the file name that cannot be found.
Read more >Xamarin Android Bug - Developer Community
Error The “LinkAssemblies” task failed unexpectedly. System.IO.FileNotFoundException: Could not load assembly 'FireWolf, Version=0.0.0.0, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Here is another repro project: TestAndroidX.zip
In debug mode, an image will be displayed on the main page. In release mode, the image is not displayed, because of the exception.
The exception is only happening with
<BundleAssemblies>True</BundleAssemblies>
. It makes no difference whether R8 or Linker are enabled or not. I’m using XF 4.5.0. This exception can be easily reproduced on the emulator.Stack trace of the exception (no crash, it’s silent):
ImageElementManager: Error loading image: System.IO.FileNotFoundException: Could not load file or assembly 'Xamarin.AndroidX.AppCompat.Resources, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
File name: 'Xamarin.AndroidX.AppCompat.Resources, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
at Xamarin.Forms.Platform.Android.FileImageSourceHandler.LoadImageAsync (Xamarin.Forms.ImageSource imagesource, Android.Widget.ImageView imageView, System.Threading.CancellationToken cancellationToken)
at Xamarin.Forms.Platform.Android.ImageViewExtensions.UpdateBitmap (Android.Widget.ImageView imageView, Xamarin.Forms.IImageElement newView, Xamarin.Forms.IImageElement previousView, Xamarin.Forms.ImageSource newImageSource, Xamarin.Forms.ImageSource previousImageSource)
at Xamarin.Forms.Platform.Android.FastRenderers.ImageElementManager.TryUpdateBitmap (Xamarin.Forms.Platform.Android.IImageRendererController rendererController, Android.Widget.ImageView Control, Xamarin.Forms.IImageElement newImage, Xamarin.Forms.IImageElement previous)
@15mgm15 asked:
The workaround is to not set
$(BundleAssemblies)
=True.After internal discussion, we are strongly considering removing support for
$(BundleAssemblies)
in .NET 5, as it increases on-device memory use and slows down app startup times.