Using APK Splits for Release but not Debug build type

You can try a variation on @Geralt_Encore's answer, which avoids the separate gradlew command. In my case, I only cared to use APK splitting to reduce the released APK file size, and I wanted to do this entirely within Android Studio.

splits {
    abi {
      enable gradle.startParameter.taskNames.any { it.contains("Release") }
      reset()
      include 'x86', 'armeabi-v7a', 'mips'
      universalApk false
    }
}

From what I've seen, the Build | Generate Signed APK menu item in Android Studio generates the APK using the assembleRelease Gradle target.


You can set enable based on command line argument. I have solved kinda similar problem when I wanted to use splits only for the release version, but not for regular debug builds.

splits {
    abi {
        enable project.hasProperty('splitApks')
        reset()
        include 'x86', 'armeabi-v7a'
    }
}

And then ./gradlew -PsplitApks assembleProdRelease (prod is a flavor in my case).