Android: I have some files shared by other projects, and like them packaged under assets/.
/android/app/src/main/assets/a.xml
/projects/shared/b.xml
how to put both a.xml and b.xml under assets/ in apk?
You can add arbitrary directories to the locations that Gradle (and the Android Plugin for Gradle) looks for assets.
For example, when testing migrations in Room, we use this to get our Room-generated historical schemas added to our instrumentation test's assets:
sourceSets {
androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
}
Here, we are saying that we want to add a new directory to the set of directories that populate the assets for the androidTest
source set.
Similarly, you could do something like:
sourceSets {
main.assets.srcDirs += ...
}
where you would have to figure out the appropriate ...
to point Gradle to wherever your other files are.
Note that the sourceSets
closure goes inside the android
closure of your module's build.gradle
file.