cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CB-13580) cordova-android 6.4.0 broke build if cdvBuildMultipleApks is set to true
Date Thu, 16 Nov 2017 18:14:00 GMT

    [ https://issues.apache.org/jira/browse/CB-13580?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16255719#comment-16255719
] 

ASF GitHub Bot commented on CB-13580:
-------------------------------------

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:
users@infra.apache.org


> cordova-android 6.4.0 broke build if cdvBuildMultipleApks is set to true
> ------------------------------------------------------------------------
>
>                 Key: CB-13580
>                 URL: https://issues.apache.org/jira/browse/CB-13580
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: cordova-android
>    Affects Versions: 6.4.0
>            Reporter: David Strauß
>            Assignee: Joe Bowser
>              Labels: build
>
> With the latest cordova-android (6.4.0) builds for different product flavors (arm, x86)
do not work anymore (error e.g.: "No flavor is associated with flavor dimension ...")  because
of the changes introduced with gradle 3.0.0. With the new gradle plugin a flavorDimenson must
be specified to build different product flavors (mentioned [here|https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html?utm_source=android-studio#flavor_dimensions]
in the upgrade guide. This can be fixed by adding `flavorDimensions "default"` to build.gradle
if cdvBuildMultipleApks is set to true.
> Another change that was introduced with the new gradle version is that builds for different
architectures are put into their own directory (build/outputs/apk/<arch>/<debug|release>)
which results in APK files not being found (mentioned in the upgrade guide under the point
"Modifying variant outputs at build time may not work").
> This can be fixed by adapting the findOutputApksHelper method in GenericBuilder.js.
> An unfortunate side effect of these issues is that projects leveraging crosswalk do not
work anymore.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Mime
View raw message