I am working on a Xamarin Android project in Visual Studio. I am trying to add a xml file in drawable folder, it gets added but no resource id is being generated for it. Same thing is happening with image files.
It was working before as, I have added many images and drawables but now its not working.
So please suggest what can I do to add and use them.
Thanks!
I am trying to add a xml file in drawable folder, it gets added but no resource id is being generated for it.
Check if the resource id has been generated in Resource.designer.cs. If it has not been generated, usually clean and rebuilding the project will generate it again , unless there is a syntax error somewhere.
be sure that images doesn't have '-' symbol. For example home-button.png remove it or use '_' instead.
Related
I am trying to do one of two things
add subdirectory to the drawable folder, as I have away team and home team that need to be in separate folders.
It seems that it can not be done.
So I am trying the following where I create 'top' folders like aTeam and hTeam by adding New Resource Directory and give them the name of aTeam and hTeam with the resource type of drawable.
The folders are created in the project folder structure but they are not being displayed in the android studio project and I can not reference them?
does anyone know what i am doing wrong?
I'm working on shared project and needed to add Resources/layout folder but this leads me to error about this folder alredy existing.
In my project Resources folder only have Drawable and values subfolders. In actual file system here is also some alternative folders for drawables. But here is no layout folder.
How can I solve this problem?
Maybe it's fine to use different folder name? I can add layout_ folder without errors.
Problem was solved by removing code refering to not existing yet Resource.Layout and rebuilding solution.
Can't tell for sure what's actually solved a problem.
I have been trying to create a folder manually to keep all the styling xml files inside my android project using eclipse in windows 7. As soon as I create a xml file inside that new folder and save the xml file. My R.java goes missing. I understand that R.java is not taking in the manual changes to the project. I believe there is a way we can make changes to the project by manually adding folders and reflecting the changes to the R.java file accordingly.
So can anyone please help me out as to what do I have to do to allow manual changes in my project as described above?
the only way you can create a styles xml file, is inside a values folder, so you can't assemble all the styles files inside one folder, android will not recognize it, thus, not allowing what you are trying to do
here is a link to follow when creating a folder,
http://developer.android.com/guide/topics/resources/providing-resources.html
check this part within Table 1. Resource directories supported inside project res/ directory.
Styling XML files should go someone in your RES folder, typically some flavor of "values" (like just "values" or "values-hdpi", etc.)
Putting them somewhere else can cause errors, usually they just can't be used but also could cause Eclipse to not be able to build the R.java file correctly.
I was working on my project and it was fine until recently all of a sudden it went missing when I tried to run the project.This file is auto generated so why did this happen.
In my error log I am getting this error.
"Warning: Ignoring name conflict in resource file for name menu_settings"
Please help me out here.Thanks in advance.
R.java is autogenerated at compile time. If any error in the res folder occurs it can not be genarated. So check inside it for issue. You can use also the problems eclipse perspective
This happens if you have error in the xml files under res files, like layouts, string.xml etc.
Check your res folder, check with drawable and .xml files, if u have any error in xml Compiler will not generate R.java file and do this... Project -> Clean
check your resource file there seems some error.thats why your R.java not generating.
Checkout the Res folder specially images name and XML files follow naming convention for draw able.
In my app, I decided to change a resource (a PNG file). So, I delete the old one and add the new one with the same name. However, when I run my app in both my phone and the emulator, I still see the old picture !!
I tried all these options:
Cleaning the project.
Refreshing the project folder.
Closing the project then opening it again.
Exiting Eclipse and launch it again.
Uninstalling the old version of the app from the phone before run it again.
For those who may ask about how I use this resource (PNG file), I assign a XML selector file as an ImageButton's drawable. My resource is referenced in that XML file.
Any ideas will be appreciated.
You should change the Modified Date of the file to later. I did it.
Use this http://www.nirsoft.net/utils/filedatech.html
Look through your project's folders for other png files. Many mobile platforms use pngcrush to optimize pngs for mobile, and it is caching them somewhere. When you replaced the file, the IDE didn't notice and hasn't recrushed the new file. The old files will be somewhere in either the workspace's folder, or less likely, Eclipse's application support folders.
Are you on Windows, Mac, or Linux?
Changing an image resource file won't cause Eclipse to build a new version. Try modifying a source file by adding a new line, deleting the line, then saving the file. Eclipse should then rebuild your app when you launch it.
You just need to clean the project before rebuilding it, this removes all previous states and should update resource files if you've changed them in anyway.
Eclipse has a bad habit of compiling all your code to a structure within it's .metadata directory. Not sure if this is the case for your mobile app though.
Try searching the .metadata directory for the original png and modifying/deleting it there. We've had the same issue with deploying to web servers previously and Eclipse not picking up the changes.
I solved it.
The trick was to choose a different name for my image, modify my xml selector file and re-build the project.
Thanks