• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps In Gradle splits{}, why use include and universalApk true

ac4android

Well-Known Member
Hi, I am working through some gradles and found they fail on some CPU architecture.

On closer look, the gradle use this:
Code:
splits{
     abi {
          enable true
          reset()
          include 'armeabi', 'armeabi-v7a'
          universalApk true
     }
}

Why specify the CPU in the "include" and a universalApk on top?

If you want all the architecture in the APK,, wouldn't "universalApk true" be enough?
 
I've never used splits myself, but from reading the documentation, what happens is that multiple APKs are generated, depending on what you include in the abi block.

"universalApk
If true, Gradle generates a universal APK in addition to per-ABI APKs. A universal APK contains code and resources for all ABIs in a single APK. The default value is false. Note that this option is only available in the splits.abi block. When building multiple APKs based on screen density, Gradle always generates a universal APK that contains code and resources for all screen densities."

So you get multiple APKs, plus a univerasal APK. You can of course set the parameter to false, if you don't need the universal APK.

https://developer.android.com/studio/build/configure-apk-splits.html

If you only wanted a universal architecture APK, then I don't see the point of using splits in the first place, as you could simply use the minsdkversion, and targetsdkversion in the build file as normal, to produce an APK that covers your whole range of APIs.
 
"...When building multiple APKs based on screen density, Gradle always generates a universal APK that contains code and resources for all screen densities...."

If that is so, then just leave it at universalApk, and you get the whole monty, don't bother with "include 'x86', 'x86_64' etc"

And since we are onto screen density and size, if I were to code for a Droid and a Tablet, wouldn't I use resource type, screen density etc You see it in
app/src/main/res/layout
app/src/main/res/layout-large-land // for landscape

This is important if you rotate your tablet.
 
Well yes, you would normally use the res/layout area to handle the various screen sizes/densities/orientation. But the point is that using this method generates only one APK, including everything.
The idea of the splits is to create APKs which target only specific screen densities, resulting in smaller individual APKs.
 
Back
Top Bottom