Aurous
Aurous

Reputation: 211

How to solve this error? - 'Resource.Layout' does not contain a definition for axml file

Am new to Xamarin and is currently building a very simple app using the tutorial from Youtube. Am just in a middle of the video when I got this error even tho I carefully followed all instructions. And even the instructor in the video was able to run his app successfully

CLICK THIS FOR IMAGE REFERENCE

Here's the code where I'm getting the error:

var view = inflater.Inflate(Resource.Layout.SignUp, container, false);

Upvotes: 8

Views: 11675

Answers (8)

Stuart Aitken
Stuart Aitken

Reputation: 1012

I had a lot of "XXX" does not contain "XXX" errors like this after a git reverse operation. Very annoying.

I tried all the solutions I could find, all without luck. Finally I magically fixed it by going to the Android project properties, Android Options, then unchecked "Use Fast Deployment (debug mode only)". I then built the project and it worked. Then I went back and checked that option so it was back to normal, and everything is fine.

Upvotes: 0

Gustavo Reyes
Gustavo Reyes

Reputation: 1

In my case my Main file was configured in the Build Action as AndroidResourceAnalysisConfig and then change property to AndroidResource then Build my project and it works.

Upvotes: 0

M. Wiśnicki
M. Wiśnicki

Reputation: 6203

In Xamarin.Android this problem can be resolved by saving other axml/xml file. Many times cleaning solution, deleting bins/obj doesn't working for me.

Upvotes: 0

Nick Kovalsky
Nick Kovalsky

Reputation: 6472

Resource.designer.cs was excluded from project. Solved by including back.

Upvotes: 1

IvanF.
IvanF.

Reputation: 543

In my Resource.Layout.toolbar, Resource was ambiguous between Android.Resource and Xamarin.Forms.Platform.Android.Resource. Instead the one that works for me is [Project name].Droid.Resource. Clean, deleted bin/debug and now it's fine

Upvotes: 1

ang
ang

Reputation: 699

For me it is caused by namespace changes. After I corrected the namespace in project properties, then I can build again

Upvotes: 13

Aurous
Aurous

Reputation: 211

I just deleted my newly created axml file, rebuild, add it again, and this time, clean and rebuild.

Everytime I added a new axml file, I clean and rebuild. That's all, thank you :).

Upvotes: 10

FreakyAli
FreakyAli

Reputation: 16547

Actually this problem occurs when your ResourceDesigner.cs file has not yet mapped the file that you added to your resource directory. The easiest way i would suggest to handle this situation is you comment the code you are trying to write and clean build your project and it will work like a charm. Good luck!

Upvotes: 6

Related Questions