react-native-background-geolocation icon indicating copy to clipboard operation
react-native-background-geolocation copied to clipboard

Ejected Expokit and Okhttp3

Open mschipperheyn opened this issue 8 years ago • 5 comments

Hi,

We are using react-native-background-geolocation and are moving to an ejected version of Expo. We are getting the issue in https://github.com/transistorsoft/react-native-background-geolocation/issues/524

The workaround we are considering is basically:

  • Uncomment the okhttp compilation line
  • Not use server side interaction

But this has to be done with each yarn install

Your Environment

  • Plugin version: 2.13.3
  • Platform: Android
  • OS version: 27
  • Device manufacturer / model: Nexus
  • React Native version (react-native -v): 30.0
  • Plugin config

Expected Behavior

I understand the compatibility issue caused by Expo creating a copy of Okhttp and we would like to be able to keep Expo, and the relevant code that uses okhttp is part of a pre-compiled part of the library. This is more a question of: how do we best work around this.

Options

  • Create an internal repo with react-native-background-geolocation and the uncommented gradle file
  • Proxy calls from okhttp to expo.Okhttp (somehow)
  • [...]

Any suggestions?

Actual Behavior

AGPBI: {"kind":"error","text":"Program type already present: okhttp3.internal.ws.WebSocketReader","sources":[{}],"tool":"D8"}

Steps to Reproduce

  1. Eject expo
  2. Install RNBackgroundGeoLocation
  3. Rebuild

Context

Getting RNBackgroundGeoLocation to work with Expo Ejected

Debug logs

mschipperheyn avatar Sep 20 '18 20:09 mschipperheyn

The problem is Expo using an out-dated version of okhttp @ 3.4.1, a version before OkHttp introduced breaking changes.

The latest version is 3.11.0.

I'd be asking Expo why they're stuck on such an old version of OkHttp. Expo is more trouble than it's worth.

I will add a new Gradle Config Parameter okHttpVersion.

ext {
    okHttpVersion = "3.10.0"
}

christocracy avatar Sep 20 '18 20:09 christocracy

Thanks for the quick reply! Not a 100% on if doing that on my side now should make a difference (it doesn't)

mschipperheyn avatar Sep 20 '18 21:09 mschipperheyn

I got my build to work doing the following...

  1. Update android/build.gradle with okHttpVersion (my react native build used 3.6.0)
ext {
    compileSdkVersion   = 27
    targetSdkVersion    = 27
    buildToolsVersion   = "27.0.3"
    supportLibVersion   = "27.1.1"
    playServicesVersion = "15.0.1"
    okHttpVersion       = "3.6.0"
}
  1. Update android/app/build.gradle

Replace

implementation 'com.squareup.okhttp3:okhttp:3.4.1'
implementation 'com.squareup.okhttp3:okhttp-urlconnection:3.4.1'
implementation 'com.squareup.okhttp3:okhttp-ws:3.4.1'

With

implementation "com.squareup.okhttp3:okhttp:$rootProject.okHttpVersion"
implementation "com.squareup.okhttp3:okhttp-urlconnection:$rootProject.okHttpVersion"
//implementation "com.squareup.okhttp3:okhttp-ws:3.4.1"

bpshonyak avatar Sep 28 '18 04:09 bpshonyak

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and I will leave this open.

stale[bot] avatar Jun 04 '19 17:06 stale[bot]

Closing this issue after a prolonged period of inactivity. Fell free to reopen this issue, if this still affecting you.

stale[bot] avatar Jun 11 '19 18:06 stale[bot]