Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using APK Splits for Release but not Debug build type

I've successfully implemented APK Splits so that separate APKs are generated for different ABIs.

However, for efficiency (and since I have no need for non-armeabi-v7a APKs in Debug), I would like to limit Debug builds to only generate armeabi-v7a APKs.

How can this be done?

One idea is with this:

abi {     enable true     reset()     include 'x86', 'armeabi-v7a', 'mips'     universalApk false } 

Maybe there is some way to set enable based on the Build type?

like image 663
techehcet Avatar asked Jan 04 '16 13:01

techehcet


People also ask

What is the difference between debug APK and release APK?

Major differences are the debug apk and the release apk: For debug builds the apk will be signed with the default debug signing keys with debug flag enabled. For release apk you will have to explicitly specify the apk to sign with and the debug flag will be turned off so that it cannot be debugged.

What is split config APK?

SAI (Split APKs Installer) is an App that lets you install multiple APKs as if it was a single Package.

How do I debug a release app?

Click on the package name, and in the top right of the Devices view you should see a green bug along with a number of other small buttons. Click the green bug. You should now be attached/debugging your app.

What is a universal APK?

A signed, universal APK is a single, installable APK that is signed with the same app signing key used by Play App Signing for your app. You can distribute this APK on other app stores and distribution channels such as websites so that wherever you distribute your app, it's signed with the same key.


2 Answers

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.

like image 170
Jeff P Avatar answered Sep 23 '22 12:09

Jeff P


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).

like image 21
Geralt_Encore Avatar answered Sep 23 '22 12:09

Geralt_Encore