13

I would like to create sub folders in drawable folder. I have a lot of file(such as png, xml) in drawable folder. I want to create sub folders in there to find the files easily. Can I create sub folders like that?

Thanks.

user2864740
  • 60,010
  • 15
  • 145
  • 220
user1156041
  • 2,155
  • 5
  • 24
  • 54

1 Answers1

26

This is now (sort of) possible by using Android Studio and Gradle.

Whilst subfolders are still not possible, it is possible to separate resources into different sets and have them merged by the build system.

As an example, to simplify my project, I wanted to keep theme specific drawables separate from standard drawables.

I created a new resource folder named 'res_lighttheme' as illustrated in the picture below.

Folder Structure

I then added a pointer to this folder to my build.gradle file like this. To add more than one just add another line to the definition.

Build Gradle

The result is that BOTH folders are then considered to be valid destinations for resources. A build error will be generated if there is a conflict. i.e if the same resource is included in both folders.

Kuffs
  • 35,581
  • 10
  • 79
  • 92
  • 7
    I get the following error in my theme files: `URI is not registered`. The line in question is always: ``. Do you know what it is? – letiagoalves Jan 07 '14 at 22:54
  • 1
    Could you comment on the issue that @letiagoalves brought up? – Suragch Apr 18 '15 at 08:56
  • I'm having the same problem with @letiagoalves – Petra Barus Jan 31 '17 at 02:10
  • facing same issue made a folder in layout folder and shifted the previous layouts in that folder after that getting error – JSONParser Sep 05 '17 at 05:57
  • This error will occur if you create subfolders in your *existing* resource folders. Each folder referenced must be ONE folder with NO subfolders. e.g 'src/main/res2' and 'src/main/res' are fine. 'src/main/res/res2' and 'src/main/res' are not – Kuffs Sep 05 '17 at 06:12