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 ;-)
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.
@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 馃槒
@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.
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
@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.
Added OkHttp dependency cddd160
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.
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
@czciou , which version of react-native-fetch-blob are you using ?
No problem on updating to the last release, seems fixed to me :-)
Okay, let's close this issue.
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
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.
Most helpful comment
I believe it is still not fixed as I am getting errors like:
Also, I've found that lib's
build.gradle file has
and changing it to
fixes the problem