ionic devapp crashes on Android with the "Advanced HTTP" plugin

1.4k Views Asked by At

I'm developing an ionic 4 app and I had a CORS issue so I followed this article https://ionicframework.com/docs/native/http/ to install the "advanced http" plugin. I'm using devapp to test my application.

I'm trying http.post to an Azure B2C token URL with headers as { 'Content-Type': 'application/x-www-form-urlencoded'}

  • on iOS DevApp works totally fine
  • on Android Studio emulator works fine ionic cordova run android --emulator
  • on Android Device works fine ionic cordova run android --device
  • on Android, DevApp crashes with the below error (I was able to get the logs using adb logcat and found the error)

No virtual method getHttpUrlChecked(Ljava/lang/String;)Lokhttp3/HttpUrl; in class Lokhttp3/internal/Internal; or its super classes (declaration of 'okhttp3.internal.Internal' appears in base.apk)

Some posts online suggest its a conflict between different cordova plugins, but I started from a blank template and only used "cordova-plugin-advanced-http", the DevApp instantly crashes.

Any suggestions?

Thanks in advance

1

There are 1 best solutions below

4
On

The problem in general is a conflict between okHTTP libraries:

https://github.com/silkimen/cordova-plugin-advanced-http/issues/130

Do a case-insensitive "find" ("grep") through all of your project's build files (package.json, build.gradle, config.xml, project.properties, etc. etc.) for "okHTTP". You should be able to find - and manually correct - the discrepency in the Android build.

Specifically, it looks like you'll have to hack project.properties:

https://github.com/transistorsoft/cordova-background-geolocation-lt/issues/905

Please post back what you find.

PS:

The latest 3.x version of okHTTP is 3.14.4; the latest 4.x version is 4.2.2:

https://square.github.io/okhttp/changelog

You MUST NOT use a version older than 3.4 for "set/getHttpUrlChecked()" to work.