React-native-fetch-blob: Android build failures

Created on 14 Aug 2017  路  18Comments  路  Source: wkh237/react-native-fetch-blob

Getting the following errors (and several more) when trying to do an Android build:

:react-native-fetch-blob:compileReleaseJava
./node_modules/react-native-fetch-blob/android/src/main/java/com/RNFetchBlob/RNFetchBlob.java:21: error: cannot find symbol
import com.facebook.react.modules.network.CookieJarContainer;
                                         ^
  symbol:   class CookieJarContainer
  location: package com.facebook.react.modules.network
./node_modules/react-native-fetch-blob/android/src/main/java/com/RNFetchBlob/RNFetchBlob.java:23: error: package okhttp3 does not exist
import okhttp3.OkHttpClient;
              ^
./node_modules/react-native-fetch-blob/android/src/main/java/com/RNFetchBlob/RNFetchBlob.java:24: error: package okhttp3 does not exist
import okhttp3.JavaNetCookieJar;

"react-native": "0.45.1",
"react-native-fetch-blob": "^0.10.8",

All 18 comments

"Me too" comment - but with a link to all the errors that I get: https://gist.github.com/lll000111/423b858d707daf5eba5212ca5e1f6baa

Some probably disappear with this tiny change: https://github.com/wkh237/react-native-fetch-blob/pull/238 (I still had plenty of errors even after adding compile 'com.squareup.okhttp3:okhttp:+' to the dependencies though)


EDIT: I have to clarify that the react-native run android build works. I would just like it to work when I do it as an Android Studio project. It sure helps during development if the IDE doesn't report numerous "this stuff doesn't exist, no idea what you are doing" errors in the source code.

@lll000111 Just out of interest, what does your

allprojects {
    repositories {
        maven {

section look like in android/build.gradle?

@dave-irvine

maven {
    // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
    url "$rootDir/../node_modules/react-native/android"
}

Hmm ok. I had messed with that section and when I returned it to normal everything has started working again, although I did upgrade RN to 0.47 in the meantime.

@wkh237 I think this is still an issue for @lll000111 , also I had to use the fix #238

I don't have a runtime issue (which includes building it through react-native run-android), but a development one. It runs just fine, but I don't like all the red in my Android development environment, I'm not deep enough into (i.e. not at all) into the Java _environment_. I have no problems programming in the language, but finding out anything related to packaging...

i also have that problem:
image

:react-native-fetch-blob:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
C:\Users\gebruiker\Documents\projects\tildepost-expo\node_modules\react-native-fetch-blob\android\src\main\java\com\RNFetchBlob\RNFetchBlob.java
Error:(24, 15) error: cannot find symbol class JavaNetCookieJar
Error:(54, 55) error: incompatible types: expolib_v1.okhttp3.OkHttpClient cannot be converted to okhttp3.OkHttpClient
Error:(57, 46) error: cannot find symbol class JavaNetCookieJar
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
:react-native-fetch-blob:compileReleaseJavaWithJavac FAILED
Error:Execution failed for task ':react-native-fetch-blob:compileReleaseJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
Information:BUILD FAILED

i'm using EXPO v20: https://github.com/expo/expo/issues/561

I have the same issue as well, I think this could be a dup, but would like to get some attention now that the new react-native version is out for awhile and upgrading react native breaks this repo.

what i remember is that when https://github.com/facebook/react-native/pull/11573 will be solved, this issue will be resolved too

This is my workaround

in all imports referenced by okhttp3 I replaced by expolib_v1.okhttp3

It worked. It's not the best solution but is working as supposed to.

@faustoct can you please show me an example of how that code looks? I can not get it to work for me.

@faustoct when I did this there was more errors, where exactly did you replace okhttp3 with expolib_v1.okhttp3?

@yingdongzhang Are sure you replaced ALL okhttp3 s with expolib_v1.okhttp3 s in your project by using find in path? If so, then the error is probably from okio. In any file that is getting the new error, replace import okio.whatever with import expolib_v1.okio.whatever for every import of okio in that file. Hope this helps :)

@giisethegoose thank you I have already moved my project completely out of Expo and went with just RN so fortunately this problem doesn't bother me anymore. But I still have the old branch around so I might give it a try when I have time.

@faustoct I have tried your solution and compiled the APK, but then it is getting an error : No such file or directory in rendering PDF view. How is it on your end?

@yingdongzhang I got it to work after I changed all react-native-fetch-blob from okhttp3 and okio imports to expolib_v1.okhttp3 and expolib_v1.okio:

Example:
Path: ..node_modules\react-native-fetch-blob\android\src\main\java\comRNFetchBlobRNFetchBlobBody.java

...
import expolib_v1.okhttp3.MediaType;
import expolib_v1.okhttp3.RequestBody;
import expolib_v1.okio.BufferedSink;

public class RNFetchBlobBody extends RequestBody{

InputStream requestStream;

...

@flavioltonon Hmm, that won't survive a yarn install

Guys i was facing same issues , the reason was i accidentally removed this part from gradle ,i put it back and everything worked fine
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jackdoe picture jackdoe  路  4Comments

yaronlevi picture yaronlevi  路  4Comments

nicholasstephan picture nicholasstephan  路  3Comments

mykelaballe picture mykelaballe  路  4Comments

aouaki picture aouaki  路  3Comments