2

I am working on an Android-Xamarin App with Visual Studio 2015. After I think it was the next-to-last Visual Studio Tools for Xamarin Update 4.8.0.754 I have a problem.

In the whole solution, the Resources are not found

The name 'Resource' does not exist in the current context.

As seen in this screenshot: enter image description here

A suggested potential fix is to "using Android;"

That does not help me at all, as seen in the next screenshot: enter image description here

Now the error message is

'Resource.Id' does not contain a definition for 'IDNAME'

Maybe you can help me with this problem :-)

As additional information: I also got the problem discussed in this thread: Xamarin Android project cannot build because R$anim.class is in use

These two problems occurred at the same time till now.


EDIT:

Suppose in my Solution, the Project where the Resources are missing is called "ProjectName.Client.Droid". In this Project, there are folders like "Activities", "Adapter", "Fragment", ..., AND "Resources"

In the code, I can choose for example "ProjectName.Client.Droid.Fragment", in this case, IntelliSens even suggests ".Fragments" if I type "F"

I see every folder in the project except the Resources folder.

ProjectName.Client.Droid.Fragments // works ProjectName.Client.Droid.Resources // not found 
5
  • Possibly this known bug: bugzilla.xamarin.com/show_bug.cgi?id=60343 Commented Jan 9, 2018 at 12:14
  • A Clean + Rebuild usually tends to fix this when I run into this error. Commented Jan 9, 2018 at 14:17
  • 1
    Please try our 15.6 Preview 2 build when it releases. This should fix #60343 and generally speaking this issue. Some other items you can dig into would be ensuring the Resource.designer.cs is properly generated. Try to remove that file, rebuild your project, and include the newly generated Resource.designer.cs file into your project. Clear your bin/obj folders before doing this. Commented Jan 9, 2018 at 17:27
  • Try to delete your project bin/obj files, and rebuild again. Commented Jan 10, 2018 at 5:24
  • 1
    I tried the same solution with VS2017, and all the Resources are there. But i could not deploy, because each time i run into an NullPointer Exception. @JonDouglas your answer has brought me to check the IDs of the the Resources file ... the solution was, to delete the App on my Tablet, because there were the old IDs cached. So if you are deploying on a device, make sure you delete the app from the device after you generated a new Resource.designer file. For VS2015 the problem still occurs -> i can deploy but the Resources are marked as not found Commented Jan 10, 2018 at 9:45

2 Answers 2

1

Using android class won't fix it since it is a different class from Resource that you need.
Having this problem with unknown resource means your VS is not loading properly. (Same as mine sometimes)

This can be solved by restarting the VS. Close Visual Studio, Re-open Visual Studio and Wait to reload everything and it can also fix the in use problem.

"Xamarin Android project cannot build because R$anim.class is in use" 

But another thing that may give you a problem regarding the Resource is having a different namespace with your project.


Suggested steps:
1. Please remove your import on android to start on fixing.
2. Check for namespace if different from project (Especially for copy paste codes)
3. Restart VS and then Re-open again. Please wait for the VS to load everything it needs.

Note: My other way to reload VS Resource.Designer rather than restarting is to add anything to the project like blank activity then wait for the Activity to turn blue green:

public class MyClassName : Activity <- this one 

UPDATE
Regarding the namespace. Notice that my activity namespace is same as my project name . If it has a different namespace, you will not be able to locate the Resource folder . If that's the case, you may try to put your project name same as your namespace else if you intended to change the namespace, you may import it by using namespace name;
This often happen when we're trying to copy paste a code from different project or we just made a mistake by typing a namespace and missed some letters .

enter image description here enter image description here

Sign up to request clarification or add additional context in comments.

4 Comments

Restarting in every form won't solve this problem. With Checking the namespace, do you mean to compare the namespace from the Resource.Designer with the Files?
This is not the same problem @jace. That problem was fixed in 15.5.2 which is released already.
Let me try that @JonDouglas . Do you mean visual studio version 15.5.2?
I'm referring to the problem you put in your answer was already fixed in 15.5.2 and thus this is a separate problem. See my comment above on the original question.
0

Meanwhile, this bug is fixed by updating VisualStudio and Xamarin.

1 Comment

No it isn't. Just had the same bug with current VS.Net as of 01/09/19

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.