Build Error: Invalid resource directory name: "res renderers" - android

Recently in my Xamarin.Forms solution, inside the Android project, I am getting the following build error:
Invalid resource directory name: "res renderers"
Doing a small amount of investigating I found the culprit inside the obj>Debug>res> folder. I tried deleting the folder and rebuilding but it seems to recreate it every time. I'm not sure why it started doing this and causing the IDE006 warning as well.
Anyone know how to remedy this? Is there a way to configure the Android project to ignore this folder?

I had the same problem and I did the two followings to solve:
try clean/build solution several times (after few times it worked for me)
exit and come back.
I hope this helps.

I had an .axml file inside my Android project that was causing the res/renderers file to be created that contained I suppose a corresponding file. Due to that creation I was getting the error but upon deleting the .axml file in my project, cleaning and rebuilding, the res/renderers folder stopped being created on build. I had that .axml file created before and not cause this error so I'm not completely convinced this is the real answer but it solved my problem and hopefully when I recreate the file it doesn't happen again. Perhaps use of a regular .xml would be better.

Related

'Cannot resolve symbol' and 'No resource found that matches the given name' - not a duplicate

I opened my project in Android Studio yesterday and got red everywhere with 'Cannot resolve symbol' as the description. It was completely random as no changes had been made to either the project or AS since the last time I opened the project. I ended up updating Android Studio to 2.0 and trying a bunch of solutions I found online but nothing works.
Like this guy, I have already tried:
Rebuilding the project
Cleaning the project
Syncing with Gradle Files
Closing the Project, closing AS and relaunching / reopening
File > Invalidate Caches / Restart
Examining Lint, didn't see anything obvious
Double checking all support libraries are up to date in the SDK manager
Examining my Build.gradle, although no changes and it's the same as usual, the way it was working all the time.
I have also tried the following steps (from the accepted answer):
Exiting Android Studio
Backing up ymyour project
Deleting all the .iml files and the .idea folder
Relaunching Android Studio and reimporting project
I also tried:
Removing the 'proguard' entry in build.gradle
Changing to "Use default gradle wrapper" in preferences
Another solution is to move 'buildTypes' in build.gradle but 'buildTypes' is already at the bottom of the Android section
Don't mark this as a duplicate if the "duplicate" is someone who fixed the same problem by doing something that didn't fix my problem.
Here are some screenshots:
As you can see, the color 'white' does exist:
R errors everywhere as well:
These errors are everywhere too:
Why are there two res directories and why is the one with the necessary resources a sub-directory of the java directory? Could this be related? Screenshot here:
EDIT: I created a drawable directory in the main res directory and added one of the drawables that won't get picked up by build variants. It removed the relevant 'Cannot resolve symbol' error. But when I deleted the main res and tried try to move the whole res directory in the java subdirectory to the main directory I got the following error:
EDIT: I managed to build without errors by deleting the outer res directory, copying the one inside the java one, pasting that into the main directory then deleting the one inside the java directory. How these got moved around like that I do not know. Probably caused by following the 'solution' of deleting and importing the project again. Whether it actually runs properly on a device I do not know as Android Studio is hanging for the last 20-30 minutes (as it does sometimes). If it does I may answer my own question with what I did to finally fix the problem.
The error shows you that you do not have value white in color constants.
Please check all your resource files (colors.xml, strings.xml and so on) - do you have line
<color name="white">#FFFFFF</color> in one of them?
Try creating a new project entirely, and copy and paste everything. XML files, classes, etc. That should solve your problem.
Eventually solved it by moving (by copying, pasting and deleting since AS wouldn't let me move it) a res directory that had been misplaced from deleting and re-importing the project to try and fix it initially. I don't know which one of the solutions worked but one of them must have. I just had to fix my project again after the re-importing 'solution' broke it. The res directory was a sub-directory of java when it should have been one level up as a sub-directory of main.

R.java file just went missing

I'm working on my app and for this activity I was going to build a new layout file for it. However eclipse gave me an error stating that layout was not updated in the R.java file. So I read online that modifying manifest would update the R.java file but it didn't. So I clicked on clean project and my R.java file disappeared propagating errors across all my src files. Now I heard that it could be due to layouts named with capital letters but all my layouts start with small letters. Also even if I manually add a R.java file and click on clean, the R.java disappears after. I really don't know what to do now. I also tried most of the solutions from the similar questions but to no avail.
Any error on XML files will prevent R generation.
Check for mark errors and Eclipse console (some errors when parsing XML are shown there).
Also I've seen Eclipse generates some dumb files with .out.xml or .xml.out extensions. I'm not sure why it happens, but any "allien" file on res folder also prevents R to be regenerated.
Thanks for your help guys. I tried to look at every file to check for errors but after 30 minutes of scratching my head, I just opened a new project and copied each file to the new project and that is working now.

R.java disappeared

I recently downloaded the Android Support Package and have been using it trying to get my application, running at SDK 10, to use a GridLayout.
Anyway, I cleaned my project a few times working on this error in my XML files, and then when I went back to my classes in /src, every single reference to R.* was an error.
This has happened to me before, but it usually fixes itself, and it has not yet. Does anyone know what to do?
The R.java file is no longer in my /gen folder.
It sometimes happens when you import another project First i suggest you to build it, it will create automatically .
If it's not working then try to create new project from existing source and specify the downloaded project . It worked for me
Hope this works for you let me know..
Sometimes if there is an error in your XML files R.java won't build. Go through your XML files to make sure that everything is in order (typo, forgetting to close a bracket, etc). When you fix that it should build itself again.
You can also try Adnroid Tools>Fix Project. That may help you to create gen/R.java file
Follow following steps :
In Eclipse,
=> Right Click on Project > Android Tools > Fix Project
By this way, you can fix many common problems which can help generate R.java in gen/R.java file.
There can be several reasons why this occurs. The following I have found happen to me and I have included the steps I took to resolve them.
First step is to try and clean the project (from the Project menu option I believe)
Check there are no errors with your XML files. Sometimes this is obvious from the red 'x' that appears next to an XML filename in the Project exlporer window and sometimes it is not. If it is not obvious check the 'Errors' window (whic is founf in the 'Windows' Menu option
Failing that I have found that by disabling the automatic build option, adding some arbitrary comment to an arbitrary source file, saving the source file, clean the project, remove the comment and then re-selcting automatic build can work too.
Apologies for the approximate locations for some of the Eclipse functions but I am not currently in front of Eclipse to check.
This happens when you have an error in the res folder.
Fix the error first, then do :
Project --> Clean --> Ok
Et voila !

No "R.xxx" files generated

An Android project I imported does not have the gen folder. I manually created it. I cleaned the project, closed and reopened it but still no "R.xxx" was generated under this gen folder.
In the meantime, inside my src/*.java files, all the "R.xxx" fields could not be resolved due to them not existing; e.g.
setContentView(R.layout.tutlist_fragment);
Gives me this error: "tutlist_fragment cannot be resolved or is not a field"
Any help would be greatly appreciated.
Thanks.
Be sure to check all XML files for errors. I've experienced this same issue several times, and when cleaning the project doesn't help, it's always been an XML issue. Eclipse (if you're using it) might not catch bad references and other little things in your XML, and that can cause R.java to fail to generate.

Magic behind R.java file

Recently I have been having quite some problems with R.java file. Now I have decided to do a backup and delete the file to see what happens.
Nothing happened, so I created an empty R.java file and hoped for the best. Now Eclipse seems to figure out that the file was tampered with and even issues a warning:
R.java was modified manually! Reverting to generated version!
And that's all there is. I tried building it manually but got no results.
So, I have two questions:
what should I do to force Eclipse to regenerate the file
what is happening here? How is the file created, where is the code that is generating the file?
I would appreciate any help. As usual the problem occurred just a few days before the deadline :)
I had a problem getting my Android app to compile, with seemingly inexplicable errors about failure to generate R.java.
The problem was caused by my previously killing the Android emulator during the build. Don't do that! A clue was the appearance of several left over *.out.xml files.
The solution was to select the project, click Project->Clean, and then manually delete all the *.out.xml files. Only then could I click Run->Run and have a successful build.
One more thing: I'm using Eclipse. I had to make sure that the project was selected in Package Explorer, and not just some random source file. Easy to not notice!
R.java is autogenerated on build. It's content is based on the resource files (including layouts and preferences).
When you deleted it, it was recreated, but if you create your own, you will get into trouble as the build system will not replace it.
You can simply delete it again (manually or by choosing Project->Clean) and rebuild your program.
I had this problem several times, and most of the times it is caused by some mistake in the "res" files, check everything is OK in all your res files, mainly XML, and after you can built.
For example, two common causes of this problem can be:
Didn't properly spell the name of a property in a Style in a XML file.
Didn't properly close a string in the XML of a locale file.
I found the problem - I have created a 9patch image with the patch area defined only on the Y axis (I was trying to prevent resizing on the other one).
The question remains: Why isn't there a warning about the error? Or if there is - where is it buried?
Sorry, but try to check the output in Eclipse. May be you have some errors that prevents Eclipse to finish build proccess(check your AndroidManifest.xml, is it correct?).I mean, that you should check all your resource files(string.xml, layouts, ...) and interfaces(*.aidl), may be there are some problems(inconsistent syntax, or something....) that prevent eclipse to generate R.java.
I had the same issue and it was that I had named a resource file (a .png image) using uppercase letters. (ImageButton001.png instead of imagebutton001.png).
Afther changing the name of the file my R.java came back.
Rgards,
Juan
If there's insufficient free memory the build tool will silently fail (Eclipse will not show any errors or report anything in the error log). Close your other open applications (e.g. the emulator and browser) then add a space to the application manifest file and save it.
As ponkin stated - you probably have one single problem that causes R not to re-generate itself, because of which you now have one million and one problem.
Do not try to create R class yourself. Try to think of the last XML you've been messing with, and check it for errors
I've had the same problem here
Make sure there are no errors is your Manifest file.
If you delete the resource string app_name in /res/values/strings.xml, it doesn't know how to generate R.java right.
I found this a problem when doing the HelloSpinner tutorial.
I found that an unwanted resource was causing an issue. As soon as I deleted the resource R.java was generated.
I've had this problem, to rebuild R.java I cut the code in the xml file I've just been working on (or try others if this doesn't work), deleting the file then creating another with the same name and pasting the code back into it. Hope this helps.
Something that can be good to know is that if an XML file contains a ?, then R.java is not regenerated and the error is not shown in the XML file (sometimes it shows up after a while)
I you have a line similar to:
< string name="questionmark"\>?< /string> <br>
try to change the ? to something else and see what happens to the R.java file - worked for me
I had a similar problem, I had renamed a .wav file in the Raw folder with a capital letter. When I changed to all lower case, cleaned the project and it rebuilt R.java fine.
As others stated, stay away from creating your own R.java file. I ran into the same problem when I first started with Android, and it took some time to figure out what caused by compilation errors.
What were you trying to do with the R.java file?
I had the same problem. I just went to:
Project -> Properties -> Android
and chose the right Emulator for my project, I had 3 different to choose from in that moment. I realized that i changed the Emulator in some given moment. So try to change the Emulator, that might help!
Good luck
I had the same issue with IntelliJ. The problem was that I had app_name defined twice in strings.xml For some reason, IDEA inspections didn't pick this up automatically.
I read this on another site and it helped me:
"If that doesn't fix your problem, try modifying your AndroidManifest.xml (just add a space and save). I've heard that will force the R.java to rebuild. "
So just add a space in the manifest file and then rebuild!
As a side note, usually those *.out.xml files are generated by trying to build your project whilst an xml file is focused in the editor
I had similar problem.Cleaning project didn't solve the issue and there was no error in the code or the uppercase or spaces in file names.
The solution was going to a popup window which came when you choose PROJECT-->CLEAN and then UNcheck the "Start a build immediately" option. Clean the project. Close and reopen Eclipse and then build the project (PROJECT-->BUILD).
The question remains why simple clean and build without closing Eclipse didn't worked.

Categories

Resources