Search code examples
visual-studioxamarin.formsxamarin.android

Xamarin.Forms Android project lost all references in VS2019


EDIT

I decided to just go with a fresh windows install and hope for it to fix my problem - but guess what! It didn't. My home PC installed VS2019 and AndroidSDK without any problems and it's working flawlessly, but my work laptop just don't work. I'm starting to think it has something to do with my username being "C:/users/LudvigÅslund" while my home PC got "C:/users/ludas".

End of EDIT

As I've got no clue what happened today, I'll try explain as much as possible.

Today when i opened my Xamarin.Forms project, my Android project decided to lose all of its references, and when I try to open the emulator I get the error message:

PANIC: Cannot find AVD system path. Please define ANDROID_SDK_ROOT

Emulator tablet_m-dpi_10_1in_pie_9_0_-_api_28 cannot be started.

Not quite sure what's going on. I've tried deleting and recreating my Android Emulator, changed SDK versions, etc etc. And nothing helps.

I can't access Xamarin.Forms in my Android project, nor any of the included dependencies through my PCL, it's just red everywhere.

OnCreate()-method in MainActivity.cs

My iOS project works just fine, and so does my PCL. So it's obviously something with Android - I just don't know what, or how it could become like this from shutting down the PC last night.

I've also tried to create a fresh Xamarin.Forms project and even then my .Droid-project just wont work. I've reinstalled VisualStudio 2019 with both 16.5 and 16.6 versions and nothing works.

AVD path: C:\Users\LudvigÅslund\.android\avd

SDK path: C:\Program Files (x86)\Android\android-sdk

PCL Dependencies

.Droid Depencencies/references


Solution

  • So my suspicions were correct. It was the Windows Username containing non-ascii characters (in my case, the letter Å from my lastname).

    Creating a new local user with a new username fixed this and lets me build and run Android apps once again!

    (Note that just moving the project to somewhere else but /users/{username} was not sufficient and had some references pointing to this location)