From 6dace959d2dfb8227f1b8b5b2a30b82e9bfbcbc6 Mon Sep 17 00:00:00 2001 From: Mygod Date: Wed, 6 Dec 2017 23:58:11 -0800 Subject: [PATCH] Split ABIs for smaller apk size --- mobile/build.gradle | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/mobile/build.gradle b/mobile/build.gradle index 1160705c..686a9bfb 100644 --- a/mobile/build.gradle +++ b/mobile/build.gradle @@ -1,3 +1,4 @@ +import com.android.build.OutputFile import java.util.regex.Matcher import java.util.regex.Pattern @@ -19,7 +20,7 @@ android { applicationId "com.github.shadowsocks" minSdkVersion rootProject.minSdkVersion targetSdkVersion rootProject.sdkVersion - versionCode 200 + versionCode 1 versionName "4.4.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary true @@ -37,6 +38,15 @@ android { } lintOptions { abortOnError false + checkReleaseBuilds false + } + splits { + abi { + enable true + reset() + include 'armeabi-v7a', 'arm64-v8a', 'x86' + universalApk false + } } sourceSets.main.jniLibs.srcDirs += new File(project(':core').buildDir, "intermediates/bundles/${getCurrentFlavor()}/jni") @@ -78,3 +88,11 @@ repositories { } apply plugin: 'com.google.gms.google-services' + +ext.abiCodes = ['armeabi-v7a': 1, 'arm64-v8a': 2, x86: 3] +android.applicationVariants.all { variant -> + variant.outputs.each { output -> + def baseAbiVersionCode = project.ext.abiCodes.get(output.getFilter(OutputFile.ABI)) + if (baseAbiVersionCode != null) output.versionCodeOverride = baseAbiVersionCode * 1000 + variant.versionCode + } +}