How to add subdirectories and specific files to Android assets

Viewed 157

In my repo root I have my data directory, Android project directory, and some other things. I'm trying to add my data directory as a subdirectory of the assets dir. I've tried the below code, but in only puts all the files from my data dir into assets.

sourceSets {
    main {
        assets.srcDirs '../../../data'
    }
}

How can I add the data dir with sub files and dirs to assets using Gradle? The data dir is needed by other projects than just the android project, so I don't want to move it to android-project/app/src/main/assets

Also, how can I add a specific file to assets with Gradle? I don't want to add it's parent dir to assets.srcDirs because I don't want everything in the dir, I just want this one file. Once again, this specific file is needed by other projects than just the android project, so I don't want to move it to android-project/app/src/main/assets

I'm trying to use Gradle to achieve an assets structure like this:

- assets
    - mySpecificFile
    - data
        - file1
        - file2 
        - etc
0 Answers
Related