Lack of proper documentation on gradle method resConfigs made me ask this question.
Official documentation:
- In this example, google gives a specific example of how to use it with Languages.
- In this example, google mixed Languages and Drawables
- I was unable to find any javadoc like gradle doc for the same
My (mostly wrong) understanding:
If I specify something in front of resConfigs, only that gets included in the final build, everything else does not get bundled into the apk.
Android app setup
The test app has
- Multiple languages (values-en , values-fr, ...)
- Multiple drawable folders (drawable-xxhdpi, drawable-xxxhdpi, ...)
- Multiple android versions (values-v21 , values-v7, ...)
- Multiple smallest widths(sw800, sw1000, ...)
- Multiple orientations (port,land)
- etc
My Test Observations
Note: I used android studios' apk analyzer to deduce the following results. before every test, full clean, rebuild, and prod build was generated with proguard(shrink) enabled.
Test 1:
I specified only languages resConfigs="en", "fr"
Result 1: In the apk,
- all languages vanished except en and fr
- all other resources were present (drawables, dimens, sw, orientation ...)
Test 2:
I specified only drawables resConfigs="xxhdpi"
Result 2: In the apk,
- all languages were present
- all other resources were present (dimens, sw, orientation ...)
- all drawables vanished except xxhdpi. (all other drawable folders were present, but had 0 byte files)
Test 3:
I specified languages and drawable resConfigs="en","fr","xxhdpi"
Result 3: In the apk,
- all languages vanished except en and fr
- all other resources were present (dimens, sw, orientation ...)
- all drawables vanished except xxhdpi.
Questions:
- When I only specify languages
resConfigs="en", "fr", why are other resources getting bundled into the apk (for eg: drawables) - Similary, when I only specify
resConfigs="xxhdpi", why languages and other resources get bundled - In case of gradle is using some intelligence to figure out what to exclude and what not to exclude, does there exist a list of group of resources which fall under same category, is there any documentation on it?
For eg- Language is a group, if gradle finds at least one language tag, it excludes all other languages. otherwise, includes all languages?
- Drawable is a group, if gradle finds at least one drawable tag, it excludes all other drawables. otherwise, includes all drawables?
Related Questions:
resConfigsonly worked for me on app level gradle only. When I tried to use it on a dependent module, it ignored it completely. How to make it work on a dependent module. (I was trying to integrate firebaseUI for auth)- is
resConfigsin early stages of development, or is it meant only for development purposes, and not to be used in prod setups?