0

I understand that Android Studio does not support subdirectories as specified in Can the Android drawable directory contain subdirectories?.

My question is, what is the standard way to handle this problem when working with a lot of assets? My general workflow would benefit greatly if I was able to see similar assets in one directory separate from other assets.

An example: Instead of having

drawable 
- a_asset_01
- a_asset_02
- a_asset_03
- b_asset_01
- b_asset_02
- b_asset_03

Maybe I can have somethinging "similar" to

drawable
- a_assets 
-- a_asset_01
-- a_asset_02
-- a_asset_03
- b_assets
-- b_asset_01
-- b_asset_02
-- b_asset_03

Again, I understand that this cannot be done in Android Studio, I'm simply looking for the next best thing.

  • Its stupid but you can just use the different drawable quality folders to break them apart assuming you won't use them for quality differences and just use one copy. Android will grab the only file available where ever it is in drawable. Otherwise, I guess you're stuck with needing a good naming scheme. – CmosBattery Mar 06 '19 at 16:19
  • Alternatively, you can maybe use assets with sub folders (this is supposedly possible) but then you have to code everything in which might be a bigger pain ^_^ https://stackoverflow.com/questions/15508160/how-can-i-add-a-sub-folder-to-the-raw-folder-in-my-android-app – CmosBattery Mar 06 '19 at 16:29

1 Answers1

0

You can specify new source-sets! You can have separate folders wherever you want, for example you can have ~/my_assets/A/assets, ~/my_assets/B/assets and ~/my_assets/C/assets. All you need to do is tell Gradle where to find them by adding them to the assets source sets in your build.gradle file:

android {
    compileSdkVersion 28

    sourceSets {
        main {
            assets.srcDirs += ['/full/path/to/my_assets/A/assets/', 'full/path/to/my_assets/B/assets/', 'full/path/to/my_assets/C/assets']
        }
    }
}
Izabela Orlowska
  • 7,431
  • 2
  • 20
  • 33