DEV Community

Kevin Le
Kevin Le

Posted on

Xamarin Form application failed to load Android project. Root element missing.

Since I'm responsible for the mobile client, as well as the web app and the server side NodeJS, I bounce back and forth between all of them. Last time I touched the mobile code (which was implemented using Xamarin Forms) was last week. That was when I created an archive and submitted to Google Play and Apple App Store. Both were accepted.

My Windows 10 got auto-updated a few days ago. Then this morning, trying to open my VS2017 solution, I got the error with VS 2017 failed to load the Android project. "Root element is missing". I tried with Xamarin Studio. Same thing happened. OK, reboot the computer. Still failed.

So still being patient, I googled. Someone suggested that the .csproj has a missing root element. OK, but how could it miss a root element if I didn't touch the file. Doing a git status confirms that nothing was changed. I opened it up anyway, cntrl-A, cntrl-C, go to https://www.xmlvalidation.com, and cntrl-V. XML was validated, no errors were found.

I started to become frustrated and just shouted:

Root element is missing

BTW, this is not the first time that I got burned with Xamarin. It's just the first time I decide to document.

I googled some more. Looks like someone had the same problem and posted the same question on StackOverflow. Unfortunately no answer.

Same question on StackOverflow

Googled. Tried. Still no success. Repeat. One thing I refused to do was uninstall and reinstall VS2017. Who knows how many hours that would take.

Until I found this BizTalk Tips and Tricks article.

BizTalk tips and tricks

Long story short, I renamed the .Droid.csproj.user, effectively fooling VS2017 that I deleted it, and reload the Android project. Works.

In summary, an article on BizTalk dated in 2010, way before VS2017 was born, solved a VS2017 Xamarin bug, in 2018. Go figure.

In defense of Xamarin, when it's working, it's working great. Until any update, whether it's a Xamarin update, VS update, .NET update or Windows update.

OK, let me go answer that StackOverflow question which was asked some 8 months ago, but still has no answer. And thank you to that BizTalk blog post.

Top comments (5)

Collapse
 
wallacereis profile image
wallacereis

Kevin Le, Good morning, friend!
Thank you very much for your post.
You saved my Project.
After hours searching, only your post Save my project!
Thank you so much!

Collapse
 
vipinkrishna131 profile image
Vipin Krishna

thanks....saved my day...

Collapse
 
carlomagnoconde profile image
carlomagnoconde

Thank's, you post work for my.

Collapse
 
krutikkhatri profile image
krutikkhatri

Hii
You can also use onlinexmltools.org/ for online xml converter like XML to JSON,YAML,CSV,BASE64,TSV,PlainText
XML to Minfiy XML to Beautify.

Collapse
 
fdieguez1 profile image
Fernando Dieguez • Edited

Thanks for the post. Just restarted my pc like an angry monkey (because another unrelated issue) with my vs open and then my android proyect didn't load, this solved my issue in seconds.