Is it possible to config Gradle to build few android apk files where each would be using only one resource-type folder?
I mean:
I know I could simply remove certain folders before building, but it would be nice if I could make it "automagically".
Would it be possible with using gradle "flavors"?
The resource directory is used mainly for storing files that were created before runtime, so that they can be accessed during runtime. It is not meant to be written to during runtime. So that's why when you set the resource path in Gradle it is not going to set your current working directory to the resource path.
The Gradle build system in Android Studio makes it easy to include external binaries or other library modules to your build as dependencies. The dependencies can be located on your machine or in a remote repository, and any transitive dependencies they declare are automatically included as well.
Why are there two build. gradle files in an Android Studio project?
Now we can also use api splits http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
Example From the docs link :
android {
...
splits {
density {
enable true
exclude "ldpi", "tvdpi", "xxxhdpi"
compatibleScreens 'small', 'normal', 'large', 'xlarge'
}
}
Example in AOSP: https://android.googlesource.com/platform/tools/base/+/2101d189d85dd46f865726b9b7aa0012832a6d9c/build-system/tests/regular/densitySplit/build.gradle
Its not yet possible, but 0.7.0 will have this feature.
You'll need to create 3 product flavors (or more if you want to support all densities), and you'll have a flavor property to restrict what to package in the apk.
0.7.0 will be out shortly.
Note that the Multi APK support in the Play Store does not support density as a filter, that would show up as 3 different apps on the store which is not what you'd want. Edit: this is actually supported by Multiple Apks: http://developer.android.com/google/play/publishing/multiple-apks.html
Edit2: Now that 0.7.+ is out, you can do the following:
android {
productFlavors {
mdpi {
resConfigs "mdpi", "nodpi"
}
hdpi {
resConfigs "hdpi", "nodpi"
}
xhdpi {
resConfigs "xhdpi", "nodpi"
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With