Skip to content
This repository has been archived by the owner on Mar 16, 2019. It is now read-only.

[Android] Deprecated OKHeaders from OKHttp #78

Closed
mlumbroso opened this issue Aug 7, 2016 · 13 comments
Closed

[Android] Deprecated OKHeaders from OKHttp #78

mlumbroso opened this issue Aug 7, 2016 · 13 comments

Comments

@mlumbroso
Copy link

mlumbroso commented Aug 7, 2016

On compiling with RN 0.31, I have this error message :

C:\Dev\node_modules\react-native-fetch-blob\android\src\main\java\com\RNFetchBlob\RNFetchBlobReq.java:48: error: cannot find symbol
import okhttp3.internal.http.OkHeaders;
                            ^
  symbol:   class OkHeaders
  location: package okhttp3.internal.http
Note: C:\Dev\node_modules\react-native-fetch-blob\android\src\main\java\com\RNFetchBlob\RNFetchBlobUtils.java uses or overrides a deprecated API.

:react-native-fetch-blob:compileReleaseJavaWithJavac FAILED

After a little investigation, OKHeaders.java was removed from version 3.4.0
https://github.com/square/okhttp/tree/parent-3.4.0/okhttp/src/main/java/okhttp3/internal/http

Last version to include it is 3.3.1
https://github.com/square/okhttp/tree/parent-3.3.1/okhttp/src/main/java/okhttp3/internal/http

I don't know what's best here :

  1. Either inform users to downgrade okhttp to use 3.3.1
  2. Modify the RNFetchBlobReq.java to use HttpHeaders that replace OKHeaders.

Don't know the potential drawbacks of either method, will let you make that choice ;-)

@mlumbroso
Copy link
Author

mlumbroso commented Aug 7, 2016

Trying to use
compile 'com.squareup.okhttp3:okhttp:3.3.1'
didn't work actually...

Modifying the RNFetchBlobReq.java file did work, in fact, after looking rapidly at the code, I didn't even find where OKHeaders was used.

@wkh237
Copy link
Owner

wkh237 commented Aug 7, 2016

@mlumbroso , thank you so much for doing the investigation 👍 I haven't tried the library on RN 0.31 yet, but I'll try to figure out where the problem is 😏

@wkh237
Copy link
Owner

wkh237 commented Aug 7, 2016

@mlumbroso , I've fixed the issue by removing the import state, please try install latest version 0.8.2 I suppose it should work properly now, if it doesn't please feel free reopen this issue.

@tadas-subonis
Copy link

I believe it is still not fixed as I am getting errors like:

node_modules\react-native-fetch-blob\android\src\main\java\com\RNFetchBlob\Response\RNFetchBlobDefaultResp.java:12: error: package okhttp3 does not exist
import okhttp3.Call;

Also, I've found that lib's
build.gradle file has

dependencies {
    compile 'com.facebook.react:react-native:+'
    //{RNFetchBlob_PRE_0.28_DEPDENDENCY}
}

and changing it to

dependencies {
    compile 'com.facebook.react:react-native:+'
    compile 'com.squareup.okhttp3:okhttp:3.4.1'
}

fixes the problem

@wkh237 wkh237 reopened this Aug 9, 2016
@wkh237
Copy link
Owner

wkh237 commented Aug 9, 2016

@tadas-subonis , Thank you for your information. I'll reopen this issue in case someone getting the same error, I'll take some time to fix this issue.

@wkh237
Copy link
Owner

wkh237 commented Aug 10, 2016

Added OkHttp dependency cddd160

@wkh237
Copy link
Owner

wkh237 commented Aug 10, 2016

Add Android OkHttp dependency that overrides react-native's OkHttp dependency may lead to app crash when using Debug Mode, therefore I removed the dependency again, and use another way to fix this problem.

See commit

@czciou
Copy link

czciou commented Aug 20, 2016

it is still not fixed as I am getting errors like:
RNFetchBlobBody.java:21: package okhttp3 does not exist import okhttp3.MediaType; ^ .../node_modules/react-native-fetch-blob/android/src/main/java/com/RNFetchBlob/RNFetchBlobBody.java:22: package okhttp3 does not exist import okhttp3.RequestBody;

On compiling with RN 0.31

@wkh237
Copy link
Owner

wkh237 commented Aug 20, 2016

@czciou , which version of react-native-fetch-blob are you using ?

@mlumbroso
Copy link
Author

No problem on updating to the last release, seems fixed to me :-)

@wkh237
Copy link
Owner

wkh237 commented Sep 6, 2016

Okay, let's close this issue.

@wkh237 wkh237 closed this as completed Sep 6, 2016
@ghost
Copy link

ghost commented Oct 12, 2016

Using react-native-fetch-blob 0.9.6 and I'm still getting this issue :(
(...) node_modules/react-native-fetch-blob/android/src/main/java/com/RNFetchBlob/RNFetchBlobBody.java:20: error: package okhttp3 does not exist import okhttp3.MediaType;

RN 0.33.0

@ghost
Copy link

ghost commented Oct 13, 2016

Scrap last comment. I made a brand new project and after installing rnfb lib there it was working so there must've been something wrong with the android project in my previous project.

julian-becker pushed a commit to julian-becker/react-native-fetch-blob that referenced this issue Mar 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants