Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
Created attachment 10063 [details]
Proposed file structure
In native Android development your layout and drawable folders have to be directly in Resources and then your axml, png, etc... files have to be directly within those folders. This leads to a couple of issues:
1. Having a long list of directories within Resources (especially once you start supporting multiple screen sizes / orientations.)
2. Having a long list of files within layout, drawables-xhdpi, drawables-hdpi, and so on.
I believe we can leverage the abstraction layer that is Xamarin to our advantage here, so that we can support subdirectories and still not blow up native Android. Here is what I propose to fix issue #1:
1. We allow any folder to be created within Resources rather than just the standard Android ones, so the "Invalid resource directory name" validation would be removed (or modified to detect whether the "invalid" directory has "valid" directories beneath it.) You could then create directories within Resources, e.g. "drawables", and then move folders underneath it, e.g. drawable-xhdpi, drawable-hdpi, and drawable-mdpi.
2. When the application is compiled and outputted to the build directory, the build process would recursively loop through all directories and subdirectories within Resources. Any subdirectories that don't have subdirectories within them would be copied to the root of Resources in the build output. Alternatively you could check for any directories that have a valid Resource name and copy those to the root of Resources. Any left over directories would be deleted from the build output. This would ensure that the Android application build output would be exactly the same as if there weren't subdirectories.
To fix issue #2, we would similarly allow subdirectories within the "valid" resource directories. The layout axml files, image files, etc.. could be within these subdirectories, then at build time we would simply copy the files down from the subdirectories into the parent that has a "valid" resource name, then delete the empty subdirectories left over.
I hope this ticket will be considered, as it's annoying having long lists of directories and files under Resources. Below is a screenshot of what the directory structure could look like after resolving issue #1.
Thank you for the suggestion, but we do not plan on implementing this feature.
FWIW, if you want to split your resources into multiple directories, you can provide multiple values for MonoAndroidResourcePrefix, as documented here: http://developer.xamarin.com/guides/android/under_the_hood/build_process/