Please, do you know a way how to exclude some file from Android project assets folder before multiple assets folders are merged or during the merge?
For example:
android {
sourceSets {
main {
assets.srcDirs = [fileTree(dir: 'assets1', exclude: 'myfile.txt'), 'assets2'] // does not work
assets.exclude 'assets1/myfile.txt' // does not work
assets.exclude '**/*.txt' // does not work
assets.exclude '*.txt' // does not work
}
}
packagingOptions {
exclude 'assets1/myfile.txt' // does not work
exclude '**/*.txt' // does not work
exclude '*.txt' // does not work either
}
aaptOptions {
ignoreAssetsPattern "myfile.txt" // does not work
}
}
Try this:
It's the only way to influence the
mergeDebugAssets
step (code found here).Filed a bug about this.
you can delete a file after build has finished its internal task of merging all assets using groovy task.dolast
so in this case mergeAssets.doLast where mergeAssets is provided inside #android.applicationVariants.all { variant ->
loop give access to few other task too
here i used code to delete a zip file and images folder
tested on Android 3.1.4
hope it helps
I think this should do what you want:
Source: http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-aapt-options
It's not possible at the moment.
The
packagingOptions
feature does not apply to Android resources or assets.just use
bash
to remove duplicated file from jar file
I run into the same problem and it seems adding a "!" works to indicate the file should be excluded:
"assets.exclude" might work also by adding a "!" but I haven't tested it...