dpa99c / phonegap-launch-navigator

Phonegap/Cordova plugin which launches native route navigation apps for Android, iOS and Windows
369 stars 131 forks source link

Conflict with HTTP #207

Closed pedroentringer closed 5 years ago

pedroentringer commented 5 years ago

I'm submitting a ... (check one with "x"):

Bug report

Current behavior: After installing this plugin, no HTTP requests from my application worked. It closes by itself. I removed the plugin and the HTTP requests started working again. I installed it again, and the requisitions stop. How could he resolve this conflict? The plugin used for HTTP requests is cordova-plugin-advanced-http

Environment information

cordova-android-play-services-gradle-release 1.4.3 "cordova-android-play-services-gradle-release" cordova-plugin-actionsheet 2.3.3 "ActionSheet" cordova-plugin-advanced-http 2.0.1 "Advanced HTTP plugin" cordova-plugin-android-permissions 1.0.0 "Permissions" cordova-plugin-camera 4.0.3 "Camera" cordova-plugin-device 2.0.2 "Device" cordova-plugin-dialogs 2.0.1 "Notification" cordova-plugin-file 6.0.1 "File" cordova-plugin-geolocation 4.0.1 "Geolocation" cordova-plugin-ionic-keyboard 2.1.3 "cordova-plugin-ionic-keyboard" cordova-plugin-ionic-webview 2.2.0 "cordova-plugin-ionic-webview" cordova-plugin-network-information 2.0.1 "Network Information" cordova-plugin-splashscreen 5.0.2 "Splashscreen" cordova-plugin-statusbar 2.4.2 "StatusBar" cordova-plugin-whitelist 1.3.3 "Whitelist" cordova-sqlite-storage 2.4.0 "Cordova sqlite storage plugin" ionic-plugin-keyboard 2.2.1 "Keyboard" phonegap-plugin-barcodescanner 8.0.0 "BarcodeScanner"

- Runtime issue

Android build issue:

If using an [Ionic Native Typescript wrapper]() for this plugin:

cli packages: (D:\Aplicativos\iconex-entrega\node_modules)

@ionic/cli-utils  : 1.19.2
ionic (Ionic CLI) : 3.20.0

global packages:

cordova (Cordova CLI) : 8.1.1 (cordova-lib@8.1.0)

local packages:

@ionic/app-scripts : 3.2.0
Cordova Platforms  : android 7.1.1
Ionic Framework    : ionic-angular 3.9.2

System:

Android SDK Tools : 26.1.1
Node              : v8.12.0
npm               : 6.4.1
OS                : Windows 10

Environment Variables:

ANDROID_HOME : C:\Users\pedro\AppData\Local\Android\Sdk

Misc:

backend : pro
dpa99c commented 5 years ago

cordova-plugin-advanced-http specifies v3.10.0 of the urlconnection module of the OKHTTP library as a Gradle dependency.

This plugin specifies the main okhttp3 module of the library as a Gradle dependency and by default the requested version is v3.+, so will pull in the latest 3.x version which is v3.11.0.

Hence you now have v3.10.0 of the urlconnection module and v3.11.0 of the okhttp3 module which are probably not compatible, hence your problems.

Fortunately, this plugin enables you to specify the version of the OKHTTP library that will be requested via a plugin variable. By doing so, you should be able to match the version to that requested by the other plugin which should resolve the issue:

cordova plugin add uk.co.workingedge.phonegap.plugin.launchnavigator --variable OKHTTP_VERSION=3.10.0

Since cordova-plugin-advanced-http has no equivalent way to override the version, if you were to include another plugin in your project which specified a different version of the library, you would have problems again. Therefore, you should open an issue against cordova-plugin-advanced-http to request the version of the library be made configurable as it is for this plugin.

pedroentringer commented 5 years ago

@dpa99c perfect! It worked, and you're covered in reason. Thank you!

Genarito commented 5 years ago

Love you guys! Thank you so much

Tristan10 commented 5 years ago

cordova-plugin-advanced-http specifies v3.10.0 of the urlconnection module of the OKHTTP library as a Gradle dependency.

This plugin specifies the main okhttp3 module of the library as a Gradle dependency and by default the requested version is v3.+, so will pull in the latest 3.x version which is v3.11.0.

Hence you now have v3.10.0 of the urlconnection module and v3.11.0 of the okhttp3 module which are probably not compatible, hence your problems.

Fortunately, this plugin enables you to specify the version of the OKHTTP library that will be requested via a plugin variable. By doing so, you should be able to match the version to that requested by the other plugin which should resolve the issue:

cordova plugin add uk.co.workingedge.phonegap.plugin.launchnavigator --variable OKHTTP_VERSION=3.10.0

Since cordova-plugin-advanced-http has no equivalent way to override the version, if you were to include another plugin in your project which specified a different version of the library, you would have problems again. Therefore, you should open an issue against cordova-plugin-advanced-http to request the version of the library be made configurable as it is for this plugin.

I tried setting the version like you mentioned, but my app still crashes. I double checked that the expected version for the native HTTP plugin is still 3.10.0, and it is. Do you have any other suggestions?

dpa99c commented 5 years ago

@Tristan10 check what versions are listed in your build.gradle for com.squareup.okhttp3 - i.e. check they are all 3.10.0.

Tristan10 commented 5 years ago

@dpa99c it was still 3.+ in the build.gradle file.

compile "com.squareup.okhttp3:okhttp:3.+" compile "com.squareup.okhttp3:okhttp-urlconnection:3.10.0"

Shouldn't that automatically update based on what is inside the project's root config.xml? (It won't hurt anything to manually update it in the build.gradle?)

EDIT: Even after updating it in the build.gradle, it seems to get reset to 3.+ when the project is built again.

dpa99c commented 5 years ago

Even after updating it in the build.gradle, it seems to get reset to 3.+ when the project is built again.

build.gradle is volatile in Cordova projects - each time you run a Cordova CLI command, any manual changes will get overwritten as Cordova rebuilds it dynamically.

it was still 3.+ in the build.gradle file.

This indicates to me that the plugin variable has not been applied.

If you installed this plugin with:

cordova plugin add uk.co.workingedge.phonegap.plugin.launchnavigator --variable OKHTTP_VERSION=3.10.0

Then in config.xml I'd expect to see:

<plugin name="uk.co.workingedge.phonegap.plugin.launchnavigator" spec="^4.2.2">
    <variable name="OKHTTP_VERSION" value="3.10.0" />
</plugin>

If this is not the case, I'd suggest removing+re-adding the plugin.

In build.gradle I'd expect to see:

compile "com.squareup.okhttp3:okhttp:3.10.0"

If this is not the case, I'd suggest removing+re-adding the platform.