Could not load file or assembly 'Xamarin.AndroidX.AppCompat.Resources'
See original GitHub issueXamarin.Android Version (eg: 6.0):
Version: 10.1.3.7
Operating System & Version (eg: Mac OSX 10.11):
Mac OSX 10.15.2
Support Libraries Version (eg: 23.3.0):
28.0.3
Describe your Issue:
It works well until previous version a few days ago, but build error occurs today, then I upgrade dependency libraries to the newest, error changes to:
<PackageReference Include="Xamarin.AndroidX.Migration">
<Version>1.0.0-preview05</Version>
<Version>1.0.0-rc1</Version>
</PackageReference>
[MonoDroid] 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.
[MonoDroid] File name: 'Xamarin.AndroidX.AppCompat.Resources, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
[MonoDroid] at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].Start[TStateMachine] (TStateMachine& stateMachine) [0x0002c] in <6b940a667a274fa48104ab71b2541709>:0
[MonoDroid] at Xamarin.Forms.Platform.Android.ResourceManager.GetFormsDrawableAsync (Android.Content.Context context, Xamarin.Forms.ImageSource imageSource, System.Threading.CancellationToken cancellationToken) [0x00033] in <a38b08ed6ae34fcca788cdc23b3fac01>:0
[MonoDroid] at Xamarin.Forms.Platform.Android.BottomNavigationViewUtils.SetMenuItemIcon (Android.Views.IMenuItem menuItem, Xamarin.Forms.ImageSource source, Android.Content.Context context) [0x00017] in <a38b08ed6ae34fcca788cdc23b3fac01>:0
[MonoDroid] at Xamarin.Forms.Platform.Android.BottomNavigationViewUtils.SetupMenu (Android.Views.IMenu menu, System.Int32 maxBottomItems, System.Collections.Generic.List`1[T] items, System.Int32 currentIndex, Google.Android.Material.BottomNavigation.BottomNavigationView bottomView, Android.Content.Context context) [0x001c8] in <a38b08ed6ae34fcca788cdc23b3fac01>:0
[MonoDroid] at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) [0x00000] in <6b940a667a274fa48104ab71b2541709>:0
[MonoDroid] at Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0 () [0x00000] in <78bc2a97e5be434ba8d7b494fe3c28fb>:0
[MonoDroid] at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <78bc2a97e5be434ba8d7b494fe3c28fb>:0
[MonoDroid] at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in <78bc2a97e5be434ba8d7b494fe3c28fb>:0
[MonoDroid] at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.44(intptr,intptr)
Steps to Reproduce (with link to sample solution if possible):
Include any relevant Exception Stack traces, build logs, adb logs:
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
Xamarin.AndroidX.AppCompat.Resources
Dear Xamarin Team,. Why this following error coming in my studio while running android application. I installed Xamarin.AndroidX.AppCompat.
Read more >Xamarin Android Exception while loading assemblies ...
Xamarin Android Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'Xamarin.Android.Support.Compat'.
Read more >Xamarin.AndroidX.AppCompat reference in latest Grid ...
Hi Folks, I wanted to install the latest update of your Grid Control but then i got an error during the build: "...
Read more >Fixing “Could not load assembly Xamarin.Android.Support ...
The fix that worked for me – Uninstalling Xamarin.Forms then reinstalling: Document all Nuget packages that depend on Xamarin.Forms – their ...
Read more >Unable to compile Xamarin.Android project in VS 2022 ...
I'm trying to update the Xamarin.Android app by moving the project files to a new project created with the "Android Application (Preview)" ...
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
Yes. Older stale projects can produce issues.
General guidelines:
Migrate from
packages.config
to<PackageReference />
Visual Studio for Windows has option for migration.
Update all packagest to latest versions and test application
Manage NuGet packages for Solution in Visual Studio for Windows can consolidate all packages for solution.
Change options for Android application (all configurations) [TODO]
aapt2
d8
r8
Add
Xamarin.AndroidX.Migration
package to the Android application and rebuild.Fix issues reported by migration package (packages)
In Visual Studio for Windows unload project and edit project file (
*.csproj
) by adding code snippet from migration package error.In Visual Studio for Mac unloading is not necessary - project files can be edited directly.
Save, load/reload and rebuild application
This step will most likely fail with numerous errors due to source code not being migrated (namespaces, fully qualified typenames).
Fix source code (build errors) from step 5.
This is manual step where Android.Support namespaces and [fully qualified] typenames must be replaced with AndroidX counterparts. Use tooltips available in both IDEs (Visual Studio for Windows and Mac).
Do not forget migrating Android.Support packagenames in layout files (
*.axml
). Failing to do so will cause runtime errors (inflation of binary XML file).Mapping file (for search and replace):
https://github.com/xamarin/AndroidX/blob/master/mappings/androidx-mapping.csv
also here
https://github.com/xamarin/XamarinAndroidXMigration/pull/34
I would like to point out that I was also experiencing this issue, tried everything, without any avail. It has something to do with older project configurations. For Example, the old project did not have
packages.config
, various differences in the.csproj
file.The solution I found was to create a new project, add all the same dependencies, copy over all the code and voilà, unable to reproduce the issue.