Closed alirezamirian closed 6 years ago
Looking at the plugin.xml and gradle config file for cordova-hot-code-push-local-dev-addon
, it doesn't directly depend on the OKHTTP library.
So it's possibly a downstream dependency of the socket.io-client
library that plugin uses.
You can try to manually edit platforms/android/build.gradle
and manually align the version numbers.
In the next release, I will add a plugin variable to make to the OKHTTP library version requested by this plugin configurable, but you'd still need to know what version to set it to (i.e. what is being requested by the other plugin).
Fix published in v4.2.1
Thanks for your quick response and fix.
However it seems something is missing in the fix. After following your instruction, I'm getting the following error from cordova build android
:
Could not get unknown property 'OKHTTP_VERSION' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
I created a project from scratch and added this plugin and the same error occurred.
It seems the variable OKHTTP_VERSION
is missing in the gradle file. When I add it manually by adding the following line in gradle.build, it builds successfully:
ext.OKHTTP_VERSION = '1.2.3'
It seems to work fine when I tested it - see console output below.
So, most probably this is related to cordova version. Because I'm using cordova 6.5.0
and it fails to build.
With cordova@6.5.0, in the build.gradle, we have:
compile "com.squareup.okhttp3:okhttp:$OKHTTP_VERSION"
In cordova@8.0.0:
compile "com.squareup.okhttp3:okhttp:3.10.0"
hello, i use phonegap build and the plugin on IOS build correct, but on ANDROID not found. The error is "Could not get unknown property 'OKHTTP_VERSION' for object of type..." with cli-6.5.0 how can I solve it using phonegap build? Thanks @dpa99c @alirezamirian
@juanmarinelli use the latest PGB CLI version cli-6.5.0 is old
thanks @dpa99c , I solved it using version 8.0.0
I created a before_build hook for solving this issue for cordova@6.x For anyone like me who is enforced to use older versions of cordova:
build-extras.gradle:
ext.OKHTTP_VERSION = '3.0.1'
copy-gradle-extra.js (before_build hook):
/**
* This hook is ONLY required for cordova@<8.x (or even maybe cordova@<7.x)
* We can safely remove it when migrated to latest versions of Cordova.
* More info: https://github.com/dpa99c/phonegap-launch-navigator/issues/193
* @param ctx
* @returns {PromiseLike<void>}
*/
module.exports = function (ctx) {
const fs = ctx.requireCordovaModule('fs');
const path = ctx.requireCordovaModule('path');
const deferral = ctx.requireCordovaModule('q').defer();
const platformRoot = path.join(ctx.opts.projectRoot, 'platforms/android');
const readStream = fs.createReadStream(__dirname + '/build-extras.gradle');
const writeStream = fs.createWriteStream(path.join(platformRoot, 'build-extras.gradle'));
readStream.on('error', deferral.reject);
writeStream.on('error', deferral.reject);
writeStream.on('finish', () => {
console.log('build-extras.gradle copied to android platform')
deferral.resolve();
});
try {
readStream.pipe(writeStream);
}
catch (e) {
readStream.destroy();
writeStream.end();
deferral.reject(e);
}
return deferral.promise;
};
copy-gradle-extra.js and build-extras.gradle are assumed to be in the same directory.
In config.xml:
<platform name="android">
<hook type="before_build" src="path/to/the/hook/copy-gradle-extra.js"/>
</platform>
I solved it using phonegap build 7.1.0 (rather than 8) from 6.5
hello, i use ionic cordova build The error is "Could not get unknown property 'OKHTTP_VERSION' for object of type..."
cordova --v 7.0.0 ionic --v 3.20.0 Thanks
@cikcoh try updating to cordova@8.0.0
with cordova 8 (node:25064) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): CordovaError (node:25064) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
There's no indication in that cordova@8 error message that this plugin is the cause
I'm submitting a ... (check one with "x"):
Bug report
Current behavior: If both plugins are added, build fails. It seems it's a version clash of OkHttp
Expected behavior: Successful build
Steps to reproduce:
Environment information
Cordova CLI version
cordova -v
: 6.5.0Cordova platform version
cordova platform ls
: android 6.2.3 browser 4.1.0 ios 4.3.1Plugins & versions installed in project (including this plugin):
cordova plugin ls
cordova-hot-code-push-local-dev-addon 0.4.2 "Hot Code Push Local Development Addon"cordova-hot-code-push-plugin 1.5.3 "Hot Code Push Plugin"
cordova-plugin-actionsheet 2.3.3 "ActionSheet"
cordova-plugin-camera 2.3.1 "Camera"
cordova-plugin-compat 1.2.0 "Compat"
cordova-plugin-customurlscheme 4.2.0 "Custom URL scheme"
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-dialogs 2.0.1 "Notification"
cordova-plugin-file 4.3.3 "File"
cordova-plugin-geolocation 2.4.3 "Geolocation"
cordova-plugin-inappbrowser 1.6.1 "InAppBrowser"
cordova-plugin-splashscreen 4.0.3 "Splashscreen"
cordova-plugin-statusbar 2.2.3 "StatusBar"
cordova-plugin-whitelist 1.3.2 "Whitelist"
ionic-plugin-keyboard 2.2.1 "Keyboard"
nl.madebymark.share 0.1.1 "Share"
onesignal-cordova-plugin 2.1.2 "OneSignal Push Notifications"
uk.co.workingedge.phonegap.plugin.launchnavigator 4.2.0 "Launch Navigator"
console output
FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':transformClassesWithJarMergingForDebug'. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: okhttp3/internal/ws/RealWebSocket$1.class * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED Total time: 6.16 secs Error: Command failed with exit code 1 Error output: Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Recompile with -Xlint:unchecked for details. FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':transformClassesWithJarMergingForDebug'. > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: okhttp3/internal/ws/RealWebSocket$1.class