@@ -72,6 +72,13 @@ static boolean isValidVersion(String version) {
7272 return true ;
7373}
7474
75+ /**
76+ * Internal helper function
77+ */
78+ static List<String > getSupportedABIs () {
79+ return [" armeabi-v7a" , " arm64-v8a" , " x86" , " x86_64" ];
80+ }
81+
7582/**
7683 * Read the Android ABI from user input.
7784 * supported ANDROID_ABIs are 'arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64'
@@ -80,7 +87,7 @@ static boolean isValidVersion(String version) {
8087List getAndroidABIs () {
8188 String property = project. findProperty(' ANDROID_ABI' )
8289
83- List<String > supportedABIs = [ " armeabi-v7a " , " arm64-v8a " , " x86 " , " x86_64 " ];
90+ List<String > supportedABIs = getSupportedABIs()
8491
8592 List<String > AbiFilters = new ArrayList<String > ()
8693 if (property == null ) {
@@ -193,8 +200,37 @@ String getVersion() {
193200
194201}
195202
203+ /**
204+ * Detect if we need to build an universal apk
205+ * this first checks, if this is manually request by the cli args, than it checks, if all supported ABIs are given, if that is the case, enable it too
206+ * @return Boolean
207+ */
208+ Boolean shouldBuildUniversalApk (List<String > abisToUse ) {
209+ String property = project. findProperty(' BUILD_UNIVERSAL_APK' )
210+
211+
212+ if (property != null ) {
213+ return true
214+ }
215+
216+ List<String > supportedABIs = getSupportedABIs()
217+
218+ // return true, if all abis, we support are specified
219+ for (abi in supportedABIs) {
220+ if (! abisToUse. contains(abi)) {
221+ return false ;
222+ }
223+ }
224+
225+ return true ;
226+
227+
228+ }
229+
230+
196231List<String > abisToUse = getAndroidABIs()
197232String versionString = getVersion()
233+ Boolean buildUniversalApk = shouldBuildUniversalApk(abisToUse)
198234
199235System . out. printf (" DEBUG: Using abis: %s%n" , abisToUse. join(" , " ))
200236System . out. printf (" DEBUG: Using version: %s%n" , versionString)
@@ -271,7 +307,7 @@ android {
271307 // Specifies a list of ABIs for Gradle to create APKs for.
272308 include(* abisToUse)
273309 // Specifies that you don't want to also generate a universal APK that includes all ABIs.
274- universalApk false
310+ universalApk(buildUniversalApk)
275311 }
276312 }
277313
0 commit comments