[Android] How to exclude a file from the assets folder only for release buildType

Hi Everyone,

I have a tricky question here:

How to exclude a file from the assets folder only for release buildType.
Imagine the following scenario:

I have a lot a json strings under the assets folder, with names like string_1.json, string_2.json, string_3.json

With the following snippet I can remove all files.

(gradle snippet)

aaptOptions {
    ignoreAssetsPattern "!*.json"

The problem is I want to keep some and remove some of them. For example, I want to keep string_2.json

Does the ignoreAssetsPattern has something for exclusions?

(Also this snippet will remove both for debug and release. Any help will be appreciated)

Thanks in advance.

I don’t think there is a good way to do exclusions to exclusions (effectively, explicit inclusions) via the DSL. Your other option is to move those files you want excluded to src/debug (I’m assuming you have only two build types) and leave the others.

I have these json files in a common place that I use both for debug and release. Also I have different ones on several build flavours. And now I want to simple remove some of them from the final assets folder, or the opposite, keep only 2 files using a regex or something. Is is possible?