infil00p closed pull request #417: CB-13580: (android) fix build for multiple 
apks (different product flavors)
URL: https://github.com/apache/cordova-android/pull/417
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/bin/templates/cordova/lib/builders/GenericBuilder.js 
b/bin/templates/cordova/lib/builders/GenericBuilder.js
index 770911b7c..6515533af 100644
--- a/bin/templates/cordova/lib/builders/GenericBuilder.js
+++ b/bin/templates/cordova/lib/builders/GenericBuilder.js
@@ -93,6 +93,14 @@ GenericBuilder.prototype.extractRealProjectNameFromManifest 
= function () {
 module.exports = GenericBuilder;
 
 function apkSorter (fileA, fileB) {
+    // De-prioritize arch specific builds
+    var archSpecificRE = /-x86|-arm/;
+    if (archSpecificRE.exec(fileA)) {
+        return 1;
+    } else if (archSpecificRE.exec(fileB)) {
+        return -1;
+    }
+
     // De-prioritize unsigned builds
     var unsignedRE = /-unsigned/;
     if (unsignedRE.exec(fileA)) {
@@ -101,7 +109,7 @@ function apkSorter (fileA, fileB) {
         return -1;
     }
 
-    var timeDiff = fs.statSync(fileA).mtime - fs.statSync(fileB).mtime;
+    var timeDiff = fs.statSync(fileB).mtime - fs.statSync(fileA).mtime;
     return timeDiff === 0 ? fileA.length - fileB.length : timeDiff;
 }
 
@@ -109,7 +117,14 @@ function findOutputApksHelper (dir, build_type, arch) {
     var shellSilent = shell.config.silent;
     shell.config.silent = true;
 
-    var ret = shell.ls(path.join(dir, build_type, '*.apk')).filter(function 
(candidate) {
+    // list directory recursively
+    var ret = shell.ls('-R', dir).map(function (file) {
+        // ls does not include base directory
+        return path.join(dir, file);
+    }).filter(function (file) {
+        // find all APKs
+        return file.match(/\.apk?$/i);
+    }).filter(function (candidate) {
         var apkName = path.basename(candidate);
         // Need to choose between release and debug .apk.
         if (build_type === 'debug') {
diff --git a/bin/templates/project/build.gradle 
b/bin/templates/project/build.gradle
index 76496b7f5..b870dc41b 100644
--- a/bin/templates/project/build.gradle
+++ b/bin/templates/project/build.gradle
@@ -184,6 +184,8 @@ android {
     buildToolsVersion cdvBuildToolsVersion
 
     if (Boolean.valueOf(cdvBuildMultipleApks)) {
+        flavorDimensions "default"
+
         productFlavors {
             armv7 {
                 versionCode defaultConfig.versionCode*10 + 2


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org
For additional commands, e-mail: commits-h...@cordova.apache.org

Reply via email to