From dad8eed8090706ed793c4fe6cb176a028ec5433e Mon Sep 17 00:00:00 2001 From: Morgan McMillian Date: Sat, 10 Nov 2018 07:03:05 -0800 Subject: [PATCH] Update to Cordova Android 7.1.2 --- config.xml | 2 +- package-lock.json | 117 +++++++++--------- package.json | 8 +- platforms/android/CordovaLib/build.gradle | 8 +- .../apache/cordova/CordovaResourceApi.java | 1 + .../org/apache/cordova/CordovaWebView.java | 2 +- platforms/android/android.json | 6 +- platforms/android/app/build.gradle | 9 +- .../android/app/src/main/AndroidManifest.xml | 2 +- ...ova-android-support-gradle-release.gradle} | 0 .../properties.gradle | 0 ...dova-android-support-gradle-release.gradle | 31 +++++ .../properties.gradle | 0 .../plugin/intent/IntentShim.java | 15 ++- .../android/app/src/main/res/xml/config.xml | 3 +- platforms/android/build.gradle | 4 +- platforms/android/cordova/Api.js | 2 +- .../android/cordova/lib/AndroidStudio.js | 33 +---- .../cordova/lib/builders/GradleBuilder.js | 3 +- .../cordova/lib/builders/StudioBuilder.js | 113 ++++++++--------- platforms/android/cordova/lib/check_reqs.js | 44 +++---- platforms/android/cordova/lib/emulator.js | 3 +- .../android/cordova/lib/plugin-build.gradle | 2 +- .../android/cordova/lib/pluginHandlers.js | 33 +++-- platforms/android/cordova/lib/run.js | 2 +- platforms/android/cordova/version | 2 +- platforms/android/platform_www/cordova.js | 17 +-- .../android/platform_www/cordova_plugins.js | 4 +- platforms/android/project.properties | 1 - 29 files changed, 240 insertions(+), 227 deletions(-) rename platforms/android/{cordova-android-support-gradle-release/goober_m-cordova-android-support-gradle-release.gradle => app/src/main/app/cordova-android-support-gradle-release/cordova-android-support-gradle-release.gradle} (100%) rename platforms/android/app/{ => src/main/app}/cordova-android-support-gradle-release/properties.gradle (100%) create mode 100644 platforms/android/app/src/main/cordova-android-support-gradle-release/cordova-android-support-gradle-release.gradle rename platforms/android/{ => app/src/main}/cordova-android-support-gradle-release/properties.gradle (100%) diff --git a/config.xml b/config.xml index b3d0d62..1cb6758 100644 --- a/config.xml +++ b/config.xml @@ -98,6 +98,6 @@ - + diff --git a/package-lock.json b/package-lock.json index 744cdf7..5baa093 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2017,9 +2017,9 @@ "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" }, "com-darryncampbell-cordova-plugin-intent": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/com-darryncampbell-cordova-plugin-intent/-/com-darryncampbell-cordova-plugin-intent-1.1.0.tgz", - "integrity": "sha512-KPyU4RlOl1ofliMSyHms3eyyzIAvRCEpGda5T8j3XXmYeU0YdLG7UeHat84eJWByjv8K7XhMbVu841DnipPrLg==" + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/com-darryncampbell-cordova-plugin-intent/-/com-darryncampbell-cordova-plugin-intent-1.1.1.tgz", + "integrity": "sha512-h+V54+qCFY1h5csX8lAKTxBn5DdbP/8/sm7vS6X0WZPI+OTKycxeoJC+oGtPHhlvTh4gSEVW5/MkDqANRcmaug==" }, "combined-stream": { "version": "1.0.6", @@ -2139,17 +2139,40 @@ "dev": true }, "cordova-android": { - "version": "7.1.0", - "resolved": "http://registry.npmjs.org/cordova-android/-/cordova-android-7.1.0.tgz", - "integrity": "sha1-HNNu57nRm61Q0+mEK3Mf5ZCSTdU=", + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/cordova-android/-/cordova-android-7.1.2.tgz", + "integrity": "sha512-w28HJGtfAZCT96hVH9BMppWMnmDTZplKu2NRQZN2dCr5e9r7aHpay41MYy9IBkh8+7E7lMo/jZkRwBDNr4VnEg==", "requires": { + "abbrev": "1.1.1", "android-versions": "1.3.0", - "cordova-common": "2.2.1", + "ansi": "0.3.1", + "balanced-match": "1.0.0", + "base64-js": "1.2.0", + "big-integer": "1.6.32", + "bplist-parser": "0.1.1", + "brace-expansion": "1.1.11", + "concat-map": "0.0.1", + "cordova-common": "2.2.5", + "cordova-registry-mapper": "1.1.15", "elementtree": "0.1.6", - "nopt": "3.0.6", + "glob": "5.0.15", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "nopt": "3.0.1", + "once": "1.4.0", + "path-is-absolute": "1.0.1", + "plist": "2.1.0", "properties-parser": "0.2.3", - "q": "1.5.1", - "shelljs": "0.5.3" + "q": "1.4.1", + "sax": "0.3.5", + "semver": "5.5.0", + "shelljs": "0.5.3", + "underscore": "1.9.1", + "unorm": "1.4.1", + "wrappy": "1.0.2", + "xmlbuilder": "8.2.2", + "xmldom": "0.1.27" }, "dependencies": { "abbrev": { @@ -2172,18 +2195,18 @@ "bundled": true }, "base64-js": { - "version": "0.0.8", + "version": "1.2.0", "bundled": true }, "big-integer": { - "version": "1.6.26", + "version": "1.6.32", "bundled": true }, "bplist-parser": { "version": "0.1.1", "bundled": true, "requires": { - "big-integer": "1.6.26" + "big-integer": "1.6.32" } }, "brace-expansion": { @@ -2199,7 +2222,7 @@ "bundled": true }, "cordova-common": { - "version": "2.2.1", + "version": "2.2.5", "bundled": true, "requires": { "ansi": "0.3.1", @@ -2208,12 +2231,10 @@ "elementtree": "0.1.6", "glob": "5.0.15", "minimatch": "3.0.4", - "osenv": "0.1.5", - "plist": "1.2.0", - "q": "1.5.1", - "semver": "5.5.0", + "plist": "2.1.0", + "q": "1.4.1", "shelljs": "0.5.3", - "underscore": "1.8.3", + "underscore": "1.9.1", "unorm": "1.4.1" } }, @@ -2251,10 +2272,6 @@ "version": "2.0.3", "bundled": true }, - "lodash": { - "version": "3.10.1", - "bundled": true - }, "minimatch": { "version": "3.0.4", "bundled": true, @@ -2263,7 +2280,7 @@ } }, "nopt": { - "version": "3.0.6", + "version": "3.0.1", "bundled": true, "requires": { "abbrev": "1.1.1" @@ -2276,33 +2293,16 @@ "wrappy": "1.0.2" } }, - "os-homedir": { - "version": "1.0.2", - "bundled": true - }, - "os-tmpdir": { - "version": "1.0.2", - "bundled": true - }, - "osenv": { - "version": "0.1.5", - "bundled": true, - "requires": { - "os-homedir": "1.0.2", - "os-tmpdir": "1.0.2" - } - }, "path-is-absolute": { "version": "1.0.1", "bundled": true }, "plist": { - "version": "1.2.0", + "version": "2.1.0", "bundled": true, "requires": { - "base64-js": "0.0.8", - "util-deprecate": "1.0.2", - "xmlbuilder": "4.0.0", + "base64-js": "1.2.0", + "xmlbuilder": "8.2.2", "xmldom": "0.1.27" } }, @@ -2311,7 +2311,7 @@ "bundled": true }, "q": { - "version": "1.5.1", + "version": "1.4.1", "bundled": true }, "sax": { @@ -2327,27 +2327,20 @@ "bundled": true }, "underscore": { - "version": "1.8.3", + "version": "1.9.1", "bundled": true }, "unorm": { "version": "1.4.1", "bundled": true }, - "util-deprecate": { - "version": "1.0.2", - "bundled": true - }, "wrappy": { "version": "1.0.2", "bundled": true }, "xmlbuilder": { - "version": "4.0.0", - "bundled": true, - "requires": { - "lodash": "3.10.1" - } + "version": "8.2.2", + "bundled": true }, "xmldom": { "version": "0.1.27", @@ -2356,11 +2349,19 @@ } }, "cordova-android-support-gradle-release": { - "version": "1.4.4", - "resolved": "https://registry.npmjs.org/cordova-android-support-gradle-release/-/cordova-android-support-gradle-release-1.4.4.tgz", - "integrity": "sha512-DOwZ+MX0CBoagXV6cHqfQacVjsrDea8z2wuM427AIvi2eAFvojw85o1XMCdJ4kSDMbsUUaNPw12h7uY0m+rcvg==", + "version": "1.4.7", + "resolved": "https://registry.npmjs.org/cordova-android-support-gradle-release/-/cordova-android-support-gradle-release-1.4.7.tgz", + "integrity": "sha512-3hDS3mBjSAEzKM4gZBze8G02/aNQgcww1CyUneuYPOYvleTPk3Q4OYkjmHHuE4FEgr4v9EY6j6bJqoX9pMZHgg==", "requires": { + "semver": "5.1.0", "xml2js": "0.4.19" + }, + "dependencies": { + "semver": { + "version": "5.1.0", + "resolved": "http://registry.npmjs.org/semver/-/semver-5.1.0.tgz", + "integrity": "sha1-hfLPhVBGXE3wAM99hvawVBBqueU=" + } } }, "cordova-plugin-device": { diff --git a/package.json b/package.json index 7003882..5c57158 100644 --- a/package.json +++ b/package.json @@ -29,9 +29,9 @@ "@ionic-native/splash-screen": "4.9.0", "@ionic-native/status-bar": "4.9.0", "@ionic/storage": "2.1.3", - "com-darryncampbell-cordova-plugin-intent": "^1.1.0", - "cordova-android": "7.1.0", - "cordova-android-support-gradle-release": "^1.4.4", + "com-darryncampbell-cordova-plugin-intent": "^1.1.1", + "cordova-android": "7.1.2", + "cordova-android-support-gradle-release": "^1.4.7", "cordova-plugin-device": "^2.0.2", "cordova-plugin-file": "^6.0.1", "cordova-plugin-file-transfer": "^1.7.1", @@ -42,7 +42,7 @@ "cordova-plugin-splashscreen": "^5.0.2", "cordova-plugin-telerik-imagepicker": "^2.1.8", "cordova-plugin-whitelist": "^1.3.3", - "cordova-sqlite-storage": "2.5.1", + "cordova-sqlite-storage": "^2.5.1", "ionic-angular": "3.9.2", "ionicons": "4.2.4", "moment": "^2.18.1", diff --git a/platforms/android/CordovaLib/build.gradle b/platforms/android/CordovaLib/build.gradle index 51c7c95..28c5e59 100644 --- a/platforms/android/CordovaLib/build.gradle +++ b/platforms/android/CordovaLib/build.gradle @@ -24,10 +24,10 @@ ext { buildscript { repositories { - jcenter() maven { url "https://maven.google.com" } + jcenter() } dependencies { @@ -42,7 +42,7 @@ apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.jfrog.bintray' group = 'org.apache.cordova' -version = '7.1.0' +version = '7.1.2' android { compileSdkVersion cdvCompileSdkVersion @@ -129,9 +129,9 @@ bintray { licenses = ['Apache-2.0'] labels = ['android', 'cordova', 'phonegap'] version { - name = '7.1.0' + name = '7.1.2' released = new Date() - vcsTag = '7.1.0' + vcsTag = '7.1.2' } } } diff --git a/platforms/android/CordovaLib/src/org/apache/cordova/CordovaResourceApi.java b/platforms/android/CordovaLib/src/org/apache/cordova/CordovaResourceApi.java index e725e25..3c438e2 100644 --- a/platforms/android/CordovaLib/src/org/apache/cordova/CordovaResourceApi.java +++ b/platforms/android/CordovaLib/src/org/apache/cordova/CordovaResourceApi.java @@ -263,6 +263,7 @@ public class CordovaResourceApi { } catch (FileNotFoundException e) { // Will occur if the file is compressed. inputStream = assetManager.open(assetPath); + length = inputStream.available(); } String mimeType = getMimeTypeFromPath(assetPath); return new OpenForReadResult(uri, inputStream, mimeType, length, assetFd); diff --git a/platforms/android/CordovaLib/src/org/apache/cordova/CordovaWebView.java b/platforms/android/CordovaLib/src/org/apache/cordova/CordovaWebView.java index e60db42..64d410e 100644 --- a/platforms/android/CordovaLib/src/org/apache/cordova/CordovaWebView.java +++ b/platforms/android/CordovaLib/src/org/apache/cordova/CordovaWebView.java @@ -31,7 +31,7 @@ import android.webkit.WebChromeClient.CustomViewCallback; * are not expected to implement it. */ public interface CordovaWebView { - public static final String CORDOVA_VERSION = "7.1.0"; + public static final String CORDOVA_VERSION = "7.1.2"; void init(CordovaInterface cordova, List pluginEntries, CordovaPreferences preferences); diff --git a/platforms/android/android.json b/platforms/android/android.json index be09320..d1ae1a1 100644 --- a/platforms/android/android.json +++ b/platforms/android/android.json @@ -97,7 +97,7 @@ ], "/manifest/application": [ { - "xml": "", + "xml": "", "count": 1 } ] @@ -406,12 +406,12 @@ "cordova-plugin-share-content": "1.0.0", "cordova-plugin-file": "6.0.1", "cordova-plugin-file-transfer": "1.7.1", - "com-darryncampbell-cordova-plugin-intent": "1.1.0", + "com-darryncampbell-cordova-plugin-intent": "1.1.1", "cordova-plugin-inappbrowser": "3.0.0", "cordova-plugin-whitelist": "1.3.3", "cordova-plugin-splashscreen": "5.0.2", "cordova-plugin-device": "2.0.2", - "cordova-android-support-gradle-release": "1.4.4", + "cordova-android-support-gradle-release": "1.4.7", "cordova-plugin-filepath": "1.4.2", "cordova-sqlite-storage": "2.5.1" } diff --git a/platforms/android/app/build.gradle b/platforms/android/app/build.gradle index f79f54a..c13ca2f 100644 --- a/platforms/android/app/build.gradle +++ b/platforms/android/app/build.gradle @@ -22,10 +22,10 @@ apply plugin: 'com.android.application' buildscript { repositories { mavenCentral() - jcenter() maven { url "https://maven.google.com" } + jcenter() } dependencies { @@ -91,7 +91,6 @@ ext { } // PLUGIN GRADLE EXTENSIONS START -apply from: "../cordova-android-support-gradle-release/goober_m-cordova-android-support-gradle-release.gradle" // PLUGIN GRADLE EXTENSIONS END def hasBuildExtras = file('build-extras.gradle').exists() @@ -260,9 +259,9 @@ dependencies { implementation fileTree(dir: 'libs', include: '*.jar') // SUB-PROJECT DEPENDENCIES START implementation(project(path: ":CordovaLib")) - compile "com.android.support:support-v4:27.1.0" - compile "com.android.support:support-v4:25.+" - compile "com.android.support:appcompat-v7:25.+" + compile "com.android.support:support-v4:27.+" + compile "com.android.support:support-v4:27.+" + compile "com.android.support:appcompat-v7:27.+" // SUB-PROJECT DEPENDENCIES END } diff --git a/platforms/android/app/src/main/AndroidManifest.xml b/platforms/android/app/src/main/AndroidManifest.xml index f2ff319..25bb6c0 100644 --- a/platforms/android/app/src/main/AndroidManifest.xml +++ b/platforms/android/app/src/main/AndroidManifest.xml @@ -13,7 +13,7 @@ - + diff --git a/platforms/android/cordova-android-support-gradle-release/goober_m-cordova-android-support-gradle-release.gradle b/platforms/android/app/src/main/app/cordova-android-support-gradle-release/cordova-android-support-gradle-release.gradle similarity index 100% rename from platforms/android/cordova-android-support-gradle-release/goober_m-cordova-android-support-gradle-release.gradle rename to platforms/android/app/src/main/app/cordova-android-support-gradle-release/cordova-android-support-gradle-release.gradle diff --git a/platforms/android/app/cordova-android-support-gradle-release/properties.gradle b/platforms/android/app/src/main/app/cordova-android-support-gradle-release/properties.gradle similarity index 100% rename from platforms/android/app/cordova-android-support-gradle-release/properties.gradle rename to platforms/android/app/src/main/app/cordova-android-support-gradle-release/properties.gradle diff --git a/platforms/android/app/src/main/cordova-android-support-gradle-release/cordova-android-support-gradle-release.gradle b/platforms/android/app/src/main/cordova-android-support-gradle-release/cordova-android-support-gradle-release.gradle new file mode 100644 index 0000000..1b0bd72 --- /dev/null +++ b/platforms/android/app/src/main/cordova-android-support-gradle-release/cordova-android-support-gradle-release.gradle @@ -0,0 +1,31 @@ +repositories{ + // Google APIs are now hosted at Maven + maven { + url 'https://maven.google.com' + } +} + +def PLUGIN_NAME = "cordova-android-support-gradle-release" + +// Fetch ANDROID_SUPPORT_VERSION var from properties.gradle +apply from: PLUGIN_NAME + '/properties.gradle' + +// List of libs to search for. +def LIBS = [ + 'com.android.support' +] + +def IGNORED = [ + 'multidex', + 'multidex-instrumentation' +] + +println("+-----------------------------------------------------------------"); +println("| " + PLUGIN_NAME + ": " + ANDROID_SUPPORT_VERSION); +println("+-----------------------------------------------------------------"); + +configurations.all { + resolutionStrategy.eachDependency { DependencyResolveDetails details -> + if (details.requested.group in LIBS && !(details.requested.name in IGNORED)) { details.useVersion ANDROID_SUPPORT_VERSION } + } +} diff --git a/platforms/android/cordova-android-support-gradle-release/properties.gradle b/platforms/android/app/src/main/cordova-android-support-gradle-release/properties.gradle similarity index 100% rename from platforms/android/cordova-android-support-gradle-release/properties.gradle rename to platforms/android/app/src/main/cordova-android-support-gradle-release/properties.gradle diff --git a/platforms/android/app/src/main/java/com/darryncampbell/plugin/intent/IntentShim.java b/platforms/android/app/src/main/java/com/darryncampbell/plugin/intent/IntentShim.java index b67978e..e5e2a09 100644 --- a/platforms/android/app/src/main/java/com/darryncampbell/plugin/intent/IntentShim.java +++ b/platforms/android/app/src/main/java/com/darryncampbell/plugin/intent/IntentShim.java @@ -250,8 +250,15 @@ public class IntentShim extends CordovaPlugin { JSONArray extraNames = extras.names(); for (int i = 0; i < extraNames.length(); i++) { String key = extraNames.getString(i); - String value = extras.getString(key); - result.putExtra(key, value); + Object extrasObj = extras.get(key); + if (extrasObj instanceof JSONObject) { + // The extra is a bundle + Bundle bundle = toBundle((JSONObject) extras.get(key)); + result.putExtra(key, bundle); + } else { + String value = extras.getString(key); + result.putExtra(key, value); + } } } } @@ -309,7 +316,7 @@ public class IntentShim extends CordovaPlugin { callbackContext.error("File not found: " + uriAsFile.toString()); return null; } - String PACKAGE_NAME = this.cordova.getActivity().getPackageName() + ".provider"; + String PACKAGE_NAME = this.cordova.getActivity().getPackageName() + ".darryncampbell.cordova.plugin.intent.fileprovider"; Uri uri = FileProvider.getUriForFile(this.cordova.getActivity().getApplicationContext(), PACKAGE_NAME, uriAsFile); return uri; } @@ -607,7 +614,7 @@ public class IntentShim extends CordovaPlugin { /** * Sends the provided Intent to the onNewIntentCallbackContext. - * + * * @param intent This is the intent to send to the JS layer. */ private void fireOnNewIntent(Intent intent) { diff --git a/platforms/android/app/src/main/res/xml/config.xml b/platforms/android/app/src/main/res/xml/config.xml index 89634ef..5199139 100644 --- a/platforms/android/app/src/main/res/xml/config.xml +++ b/platforms/android/app/src/main/res/xml/config.xml @@ -42,7 +42,7 @@ Goober Goober, a mobile app for pnut.io Morgan McMillian - + @@ -52,7 +52,6 @@ - diff --git a/platforms/android/build.gradle b/platforms/android/build.gradle index d982091..569004f 100644 --- a/platforms/android/build.gradle +++ b/platforms/android/build.gradle @@ -20,10 +20,10 @@ buildscript { repositories { - jcenter() maven { url "https://maven.google.com" } + jcenter() } dependencies { @@ -35,10 +35,10 @@ buildscript { allprojects { repositories { - jcenter() maven { url "https://maven.google.com" } + jcenter() } //This replaces project.properties w.r.t. build settings project.ext { diff --git a/platforms/android/cordova/Api.js b/platforms/android/cordova/Api.js index e97f538..ae4d17b 100644 --- a/platforms/android/cordova/Api.js +++ b/platforms/android/cordova/Api.js @@ -248,7 +248,7 @@ Api.prototype.addPlugin = function (plugin, installOptions) { }).then(function () { if (plugin.getFrameworks(this.platform).length === 0) return; selfEvents.emit('verbose', 'Updating build files since android plugin contained '); - // This should pick the correct builder, not just get gradle + // This should pick the correct builder, not just get gradle require('./lib/builders/builders').getBuilder(this.builder).prepBuildFiles(); }.bind(this)) // CB-11022 Return truthy value to prevent running prepare after diff --git a/platforms/android/cordova/lib/AndroidStudio.js b/platforms/android/cordova/lib/AndroidStudio.js index fbcb926..68d4d8f 100644 --- a/platforms/android/cordova/lib/AndroidStudio.js +++ b/platforms/android/cordova/lib/AndroidStudio.js @@ -6,37 +6,6 @@ /* jshint esnext: false */ -var path = require('path'); -var fs = require('fs'); -var CordovaError = require('cordova-common').CordovaError; - module.exports.isAndroidStudioProject = function isAndroidStudioProject (root) { - var eclipseFiles = ['AndroidManifest.xml', 'libs', 'res']; - var androidStudioFiles = ['app', 'app/src/main']; - - // assume it is an AS project and not an Eclipse project - var isEclipse = false; - var isAS = true; - - if (!fs.existsSync(root)) { - throw new CordovaError('AndroidStudio.js:inAndroidStudioProject root does not exist: ' + root); - } - - // if any of the following exists, then we are not an ASProj - eclipseFiles.forEach(function (file) { - if (fs.existsSync(path.join(root, file))) { - isEclipse = true; - } - }); - - // if it is NOT an eclipse project, check that all required files exist - if (!isEclipse) { - androidStudioFiles.forEach(function (file) { - if (!fs.existsSync(path.join(root, file))) { - console.log('missing file :: ' + file); - isAS = false; - } - }); - } - return (!isEclipse && isAS); + return true; }; diff --git a/platforms/android/cordova/lib/builders/GradleBuilder.js b/platforms/android/cordova/lib/builders/GradleBuilder.js index 8237c73..b955db1 100644 --- a/platforms/android/cordova/lib/builders/GradleBuilder.js +++ b/platforms/android/cordova/lib/builders/GradleBuilder.js @@ -24,6 +24,7 @@ var path = require('path'); var shell = require('shelljs'); var superspawn = require('cordova-common').superspawn; var CordovaError = require('cordova-common').CordovaError; +var events = require('cordova-common').events; var check_reqs = require('../check_reqs'); var GenericBuilder = require('./GenericBuilder'); @@ -178,7 +179,7 @@ GradleBuilder.prototype.prepBuildFiles = function () { }; subProjects.forEach(function (p) { - console.log('Subproject Path: ' + p); + events.emit('log', 'Subproject Path: ' + p); var libName = p.replace(/[/\\]/g, ':').replace(name + '-', ''); depsList += ' implementation(project(path: "' + libName + '"))'; insertExclude(p); diff --git a/platforms/android/cordova/lib/builders/StudioBuilder.js b/platforms/android/cordova/lib/builders/StudioBuilder.js index 8322e15..1689e16 100644 --- a/platforms/android/cordova/lib/builders/StudioBuilder.js +++ b/platforms/android/cordova/lib/builders/StudioBuilder.js @@ -23,6 +23,7 @@ var util = require('util'); var path = require('path'); var shell = require('shelljs'); var spawn = require('cordova-common').superspawn.spawn; +var events = require('cordova-common').events; var CordovaError = require('cordova-common').CordovaError; var check_reqs = require('../check_reqs'); @@ -167,7 +168,7 @@ StudioBuilder.prototype.prepBuildFiles = function () { } }; subProjects.forEach(function (p) { - console.log('Subproject Path: ' + p); + events.emit('log', 'Subproject Path: ' + p); var libName = p.replace(/[/\\]/g, ':').replace(name + '-', ''); if (libName !== 'app') { depsList += ' implementation(project(path: ":' + libName + '"))'; @@ -214,28 +215,28 @@ StudioBuilder.prototype.prepBuildFiles = function () { StudioBuilder.prototype.prepEnv = function (opts) { var self = this; return check_reqs.check_gradle() - .then(function (gradlePath) { - return self.runGradleWrapper(gradlePath); - }).then(function () { - return self.prepBuildFiles(); - }).then(function () { - // If the gradle distribution URL is set, make sure it points to version we want. - // If it's not set, do nothing, assuming that we're using a future version of gradle that we don't want to mess with. - // For some reason, using ^ and $ don't work. This does the job, though. - var distributionUrlRegex = /distributionUrl.*zip/; - var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'https\\://services.gradle.org/distributions/gradle-4.1-all.zip'; - var gradleWrapperPropertiesPath = path.join(self.root, 'gradle', 'wrapper', 'gradle-wrapper.properties'); - shell.chmod('u+w', gradleWrapperPropertiesPath); - shell.sed('-i', distributionUrlRegex, 'distributionUrl=' + distributionUrl, gradleWrapperPropertiesPath); + .then(function (gradlePath) { + return self.runGradleWrapper(gradlePath); + }).then(function () { + return self.prepBuildFiles(); + }).then(function () { + // If the gradle distribution URL is set, make sure it points to version we want. + // If it's not set, do nothing, assuming that we're using a future version of gradle that we don't want to mess with. + // For some reason, using ^ and $ don't work. This does the job, though. + var distributionUrlRegex = /distributionUrl.*zip/; + var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'https\\://services.gradle.org/distributions/gradle-4.1-all.zip'; + var gradleWrapperPropertiesPath = path.join(self.root, 'gradle', 'wrapper', 'gradle-wrapper.properties'); + shell.chmod('u+w', gradleWrapperPropertiesPath); + shell.sed('-i', distributionUrlRegex, 'distributionUrl=' + distributionUrl, gradleWrapperPropertiesPath); - var propertiesFile = opts.buildType + SIGNING_PROPERTIES; - var propertiesFilePath = path.join(self.root, propertiesFile); - if (opts.packageInfo) { - fs.writeFileSync(propertiesFilePath, TEMPLATE + opts.packageInfo.toProperties()); - } else if (isAutoGenerated(propertiesFilePath)) { - shell.rm('-f', propertiesFilePath); - } - }); + var propertiesFile = opts.buildType + SIGNING_PROPERTIES; + var propertiesFilePath = path.join(self.root, propertiesFile); + if (opts.packageInfo) { + fs.writeFileSync(propertiesFilePath, TEMPLATE + opts.packageInfo.toProperties()); + } else if (isAutoGenerated(propertiesFilePath)) { + shell.rm('-f', propertiesFilePath); + } + }); }; /* @@ -247,33 +248,33 @@ StudioBuilder.prototype.build = function (opts) { var args = this.getArgs(opts.buildType === 'debug' ? 'debug' : 'release', opts); return spawn(wrapper, args, {stdio: 'pipe'}) - .progress(function (stdio) { - if (stdio.stderr) { - /* - * Workaround for the issue with Java printing some unwanted information to - * stderr instead of stdout. - * This function suppresses 'Picked up _JAVA_OPTIONS' message from being - * printed to stderr. See https://issues.apache.org/jira/browse/CB-9971 for - * explanation. - */ - var suppressThisLine = /^Picked up _JAVA_OPTIONS: /i.test(stdio.stderr.toString()); - if (suppressThisLine) { - return; + .progress(function (stdio) { + if (stdio.stderr) { + /* + * Workaround for the issue with Java printing some unwanted information to + * stderr instead of stdout. + * This function suppresses 'Picked up _JAVA_OPTIONS' message from being + * printed to stderr. See https://issues.apache.org/jira/browse/CB-9971 for + * explanation. + */ + var suppressThisLine = /^Picked up _JAVA_OPTIONS: /i.test(stdio.stderr.toString()); + if (suppressThisLine) { + return; + } + process.stderr.write(stdio.stderr); + } else { + process.stdout.write(stdio.stdout); } - process.stderr.write(stdio.stderr); - } else { - process.stdout.write(stdio.stdout); - } - }).catch(function (error) { - if (error.toString().indexOf('failed to find target with hash string') >= 0) { - return check_reqs.check_android_target(error).then(function () { - // If due to some odd reason - check_android_target succeeds - // we should still fail here. - return Q.reject(error); - }); - } - return Q.reject(error); - }); + }).catch(function (error) { + if (error.toString().indexOf('failed to find target with hash string') >= 0) { + return check_reqs.check_android_target(error).then(function () { + // If due to some odd reason - check_android_target succeeds + // we should still fail here. + return Q.reject(error); + }); + } + return Q.reject(error); + }); }; StudioBuilder.prototype.clean = function (opts) { @@ -283,16 +284,16 @@ StudioBuilder.prototype.clean = function (opts) { return Q().then(function () { return spawn(wrapper, args, {stdio: 'inherit'}); }) - .then(function () { - shell.rm('-rf', path.join(builder.root, 'out')); + .then(function () { + shell.rm('-rf', path.join(builder.root, 'out')); - ['debug', 'release'].forEach(function (config) { - var propertiesFilePath = path.join(builder.root, config + SIGNING_PROPERTIES); - if (isAutoGenerated(propertiesFilePath)) { - shell.rm('-f', propertiesFilePath); - } + ['debug', 'release'].forEach(function (config) { + var propertiesFilePath = path.join(builder.root, config + SIGNING_PROPERTIES); + if (isAutoGenerated(propertiesFilePath)) { + shell.rm('-f', propertiesFilePath); + } + }); }); - }); }; module.exports = StudioBuilder; diff --git a/platforms/android/cordova/lib/check_reqs.js b/platforms/android/cordova/lib/check_reqs.js index 4a22360..d9c5f99 100644 --- a/platforms/android/cordova/lib/check_reqs.js +++ b/platforms/android/cordova/lib/check_reqs.js @@ -41,17 +41,6 @@ function forgivingWhichSync (cmd) { } } -function tryCommand (cmd, errMsg, catchStderr) { - var d = Q.defer(); - child_process.exec(cmd, function (err, stdout, stderr) { - if (err) d.reject(new CordovaError(errMsg)); - // Sometimes it is necessary to return an stderr instead of stdout in case of success, since - // some commands prints theirs output to stderr instead of stdout. 'javac' is the example - else d.resolve((catchStderr ? stderr : stdout).trim()); - }); - return d.promise; -} - module.exports.isWindows = function () { return (os.platform() === 'win32'); }; @@ -207,19 +196,22 @@ module.exports.check_java = function () { } } }).then(function () { - var msg = - 'Failed to run "javac -version", make sure that you have a JDK installed.\n' + - 'You can get it from: http://www.oracle.com/technetwork/java/javase/downloads.\n'; - if (process.env['JAVA_HOME']) { - msg += 'Your JAVA_HOME is invalid: ' + process.env['JAVA_HOME'] + '\n'; - } - // We use tryCommand with catchStderr = true, because - // javac writes version info to stderr instead of stdout - return tryCommand('javac -version', msg, true).then(function (output) { - // Let's check for at least Java 8, and keep it future proof so we can support Java 10 - var match = /javac ((?:1\.)(?:[8-9]\.)(?:\d+))|((?:1\.)(?:[1-9]\d+\.)(?:\d+))/i.exec(output); - return match && match[1]; - }); + return Q.denodeify(child_process.exec)('javac -version') + .then(outputs => { + // outputs contains two entries: stdout and stderr + // Java <= 8 writes version info to stderr, Java >= 9 to stdout + const output = outputs.join('').trim(); + const match = /javac\s+([\d.]+)/i.exec(output); + return match && match[1]; + }, () => { + var msg = + 'Failed to run "javac -version", make sure that you have a JDK installed.\n' + + 'You can get it from: http://www.oracle.com/technetwork/java/javase/downloads.\n'; + if (process.env['JAVA_HOME']) { + msg += 'Your JAVA_HOME is invalid: ' + process.env['JAVA_HOME'] + '\n'; + } + throw new CordovaError(msg); + }); }); }; @@ -366,8 +358,8 @@ module.exports.run = function () { console.log('ANDROID_HOME=' + process.env['ANDROID_HOME']); console.log('JAVA_HOME=' + process.env['JAVA_HOME']); - if (!values[0]) { - throw new CordovaError('Requirements check failed for JDK 1.8 or greater'); + if (!String(values[0]).startsWith('1.8.')) { + throw new CordovaError('Requirements check failed for JDK 1.8'); } if (!values[1]) { diff --git a/platforms/android/cordova/lib/emulator.js b/platforms/android/cordova/lib/emulator.js index 305e2e3..63ed302 100644 --- a/platforms/android/cordova/lib/emulator.js +++ b/platforms/android/cordova/lib/emulator.js @@ -344,7 +344,8 @@ module.exports.wait_for_emulator = function (port) { }, function (error) { if ((error && error.message && (error.message.indexOf('not found') > -1)) || - (error.message.indexOf('device offline') > -1)) { + (error.message.indexOf('device offline') > -1) || + (error.message.indexOf('device still connecting') > -1)) { // emulator not yet started, continue waiting return self.wait_for_emulator(port); } else { diff --git a/platforms/android/cordova/lib/plugin-build.gradle b/platforms/android/cordova/lib/plugin-build.gradle index bf8c59a..fdef1f7 100644 --- a/platforms/android/cordova/lib/plugin-build.gradle +++ b/platforms/android/cordova/lib/plugin-build.gradle @@ -20,10 +20,10 @@ buildscript { repositories { - jcenter() maven { url "https://maven.google.com" } + jcenter() } // Switch the Android Gradle plugin version requirement depending on the diff --git a/platforms/android/cordova/lib/pluginHandlers.js b/platforms/android/cordova/lib/pluginHandlers.js index 842489a..a3ebed0 100644 --- a/platforms/android/cordova/lib/pluginHandlers.js +++ b/platforms/android/cordova/lib/pluginHandlers.js @@ -34,15 +34,7 @@ var handlers = { // a later plugins release. This is for legacy plugins to work with Cordova. if (options && options.android_studio === true) { - // If a Java file is using the new directory structure, don't penalize it - if (!obj.targetDir.includes('app/src/main')) { - if (obj.src.endsWith('.java')) { - dest = path.join('app/src/main/java', obj.targetDir.substring(4), path.basename(obj.src)); - } else if (obj.src.endsWith('.xml')) { - // We are making a huge assumption here that XML files will be going to res/xml or values/xml - dest = path.join('app/src/main', obj.targetDir, path.basename(obj.src)); - } - } + dest = studioPathRemap(obj); } if (options && options.force) { @@ -55,10 +47,16 @@ var handlers = { var dest = path.join(obj.targetDir, path.basename(obj.src)); if (options && options.android_studio === true) { - dest = path.join('app/src/main/java', obj.targetDir.substring(4), path.basename(obj.src)); + dest = studioPathRemap(obj); } - deleteJava(project.projectDir, dest); + // TODO: Add Koltin extension to uninstall, since they are handled like Java files + if (obj.src.endsWith('java')) { + deleteJava(project.projectDir, dest); + } else { + // Just remove the file, not the whole parent directory + removeFile(project.projectDir, dest); + } } }, 'lib-file': { @@ -318,3 +316,16 @@ function removeFileAndParents (baseDir, destFile, stopper) { function generateAttributeError (attribute, element, id) { return 'Required attribute "' + attribute + '" not specified in <' + element + '> element from plugin: ' + id; } + +function studioPathRemap (obj) { + // If a Java file is using the new directory structure, don't penalize it + if (!obj.targetDir.includes('app/src/main')) { + if (obj.src.endsWith('.java')) { + return path.join('app/src/main/java', obj.targetDir.substring(4), path.basename(obj.src)); + } else { + // For all other files, add 'app/src/main' to the targetDir if it didn't have it already + return path.join('app/src/main', obj.targetDir, path.basename(obj.src)); + } + } + +} diff --git a/platforms/android/cordova/lib/run.js b/platforms/android/cordova/lib/run.js index b97fce2..4d7927c 100644 --- a/platforms/android/cordova/lib/run.js +++ b/platforms/android/cordova/lib/run.js @@ -108,7 +108,7 @@ module.exports.run = function (runOptions) { // format than emulator.install expects. // TODO: Update emulator/device.install to handle this change return build.run.call(self, runOptions, resolvedTarget).then(function (buildResults) { - if (resolvedTarget.isEmulator) { + if (resolvedTarget && resolvedTarget.isEmulator) { return emulator.wait_for_boot(resolvedTarget.target).then(function () { return emulator.install(resolvedTarget, buildResults); }); diff --git a/platforms/android/cordova/version b/platforms/android/cordova/version index 5d6e2b6..6f490b8 100755 --- a/platforms/android/cordova/version +++ b/platforms/android/cordova/version @@ -20,7 +20,7 @@ */ // Coho updates this line: -var VERSION = "7.1.0"; +var VERSION = "7.1.2"; module.exports.version = VERSION; diff --git a/platforms/android/platform_www/cordova.js b/platforms/android/platform_www/cordova.js index 1f2cdee..a9f8bb0 100644 --- a/platforms/android/platform_www/cordova.js +++ b/platforms/android/platform_www/cordova.js @@ -1,5 +1,5 @@ // Platform: android -// 4450a4cea50616e080a82e8ede9e3d6a1fe3c3ec +// 9e8e1b716252c4a08abcd31a13013b868d6f4141 /* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file @@ -19,7 +19,7 @@ under the License. */ ;(function() { -var PLATFORM_VERSION_BUILD_LABEL = '7.1.0'; +var PLATFORM_VERSION_BUILD_LABEL = '7.1.2'; // file: src/scripts/require.js /* jshint -W079 */ @@ -307,6 +307,7 @@ var cordova = { } catch (err) { var msg = 'Error in ' + (isSuccess ? 'Success' : 'Error') + ' callbackId: ' + callbackId + ' : ' + err; console && console.log && console.log(msg); + console && console.log && err.stack && console.log(err.stack); cordova.fireWindowEvent('cordovacallbackerror', { 'message': msg }); throw err; } @@ -326,7 +327,7 @@ module.exports = cordova; }); -// file: /Users/steveng/repo/cordova/cordova-android/cordova-js-src/android/nativeapiprovider.js +// file: /Users/brodybits/Documents/cordova/cordova-android/cordova-js-src/android/nativeapiprovider.js define("cordova/android/nativeapiprovider", function(require, exports, module) { /** @@ -349,7 +350,7 @@ module.exports = { }); -// file: /Users/steveng/repo/cordova/cordova-android/cordova-js-src/android/promptbasednativeapi.js +// file: /Users/brodybits/Documents/cordova/cordova-android/cordova-js-src/android/promptbasednativeapi.js define("cordova/android/promptbasednativeapi", function(require, exports, module) { /** @@ -881,7 +882,7 @@ module.exports = channel; }); -// file: /Users/steveng/repo/cordova/cordova-android/cordova-js-src/exec.js +// file: /Users/brodybits/Documents/cordova/cordova-android/cordova-js-src/exec.js define("cordova/exec", function(require, exports, module) { /** @@ -1639,7 +1640,7 @@ exports.reset(); }); -// file: /Users/steveng/repo/cordova/cordova-android/cordova-js-src/platform.js +// file: /Users/brodybits/Documents/cordova/cordova-android/cordova-js-src/platform.js define("cordova/platform", function(require, exports, module) { // The last resume event that was received that had the result of a plugin call. @@ -1749,7 +1750,7 @@ function onMessageFromNative(msg) { }); -// file: /Users/steveng/repo/cordova/cordova-android/cordova-js-src/plugin/android/app.js +// file: /Users/brodybits/Documents/cordova/cordova-android/cordova-js-src/plugin/android/app.js define("cordova/plugin/android/app", function(require, exports, module) { var exec = require('cordova/exec'); @@ -2185,4 +2186,4 @@ window.cordova = require('cordova'); require('cordova/init'); -})(); \ No newline at end of file +})(); diff --git a/platforms/android/platform_www/cordova_plugins.js b/platforms/android/platform_www/cordova_plugins.js index d6e5719..171ab8a 100644 --- a/platforms/android/platform_www/cordova_plugins.js +++ b/platforms/android/platform_www/cordova_plugins.js @@ -262,12 +262,12 @@ module.exports.metadata = "cordova-plugin-share-content": "1.0.0", "cordova-plugin-file": "6.0.1", "cordova-plugin-file-transfer": "1.7.1", - "com-darryncampbell-cordova-plugin-intent": "1.1.0", + "com-darryncampbell-cordova-plugin-intent": "1.1.1", "cordova-plugin-inappbrowser": "3.0.0", "cordova-plugin-whitelist": "1.3.3", "cordova-plugin-splashscreen": "5.0.2", "cordova-plugin-device": "2.0.2", - "cordova-android-support-gradle-release": "1.4.4", + "cordova-android-support-gradle-release": "1.4.7", "cordova-plugin-filepath": "1.4.2", "cordova-sqlite-storage": "2.5.1" }; diff --git a/platforms/android/project.properties b/platforms/android/project.properties index f8d7d29..52cc951 100644 --- a/platforms/android/project.properties +++ b/platforms/android/project.properties @@ -12,6 +12,5 @@ target=android-27 android.library.reference.1=CordovaLib android.library.reference.2=app cordova.system.library.1=com.android.support:support-v4:27.1.0 -cordova.gradle.include.1=cordova-android-support-gradle-release/goober_m-cordova-android-support-gradle-release.gradle cordova.system.library.2=com.android.support:support-v4:25.+ cordova.system.library.3=com.android.support:appcompat-v7:25.+ \ No newline at end of file