Reputation: 791
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.
A suggested potential fix is to "using Android;"
That does not help me at all, as seen in the next screenshot:
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
Upvotes: 2
Views: 5840
Reputation: 791
Meanwhile, this bug is fixed by updating VisualStudio and Xamarin.
Upvotes: 0
Reputation: 1674
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 .
Upvotes: 1