React-native-fs: Android Build failing in RN 0.59.8

Created on 3 Jun 2019  路  22Comments  路  Source: itinance/react-native-fs

RNFS Version : 2.13.3

RN Version : 0.59.8

I recently upgraded RN version to 0.59.8 and react-native-run-android command fails

I am getting the below error message

/node_modules/react-native-fs/android/src/main/java/com/rnfs/RNFSManager.java:11: error: package android.support.annotation does not exist import android.support.annotation.Nullable; ^ /Users/udbhavgoyal/Desktop/codebase/fareye-react/node_modules/react-native-fs/android/src/main/java/com/rnfs/RNFSManager.java:624: error: cannot find symbol private void sendEvent(ReactContext reactContext, String eventName, @Nullable WritableMap params) { ^ symbol: class Nullable location: class RNFSManager Note: /Users/udbhavgoyal/Desktop/codebase/fareye-react/node_modules/react-native-fs/android/src/main/java/com/rnfs/RNFSManager.java uses or overrides a deprecated API.

Most helpful comment

Can we re-open this issue ? Upgrading to 0.59.9 didn't help me at all ...

All 22 comments

The same problem.

I am facing the same problem

The same problem !!

Yes Its an issue.

Same problem . Anyone fix ?

Same.

Same here

I have that problem when I use
[email protected]
[email protected]
[email protected]
[email protected]

I installed [email protected]
And added this in android/app/build.gradle

android {
...
defaultConfig {
...
missingDimensionStrategy 'react-native-camera', 'general'
}
}

It is solved.

FYI, I have the same problem with RN 0.59.8, then i upgrade to 0.59.9 ( they just released 7 hour ago at the time i wrote this post) and the error is gone.

@bthuan Thanks man! Upgrading to 0.59.9 seems to somehow fix this bug

Can we re-open this issue ? Upgrading to 0.59.9 didn't help me at all ...

After struggling like crazy all day long, I finally found a solution and unfortunately it is not the one provided in this issue.

Basically I started having this issue after the androidx update thing.

At first I was having issues found on the main repo like this one : https://github.com/facebook/react-native/issues/25294
It was due to an AndroidManifest.xml file not being fully complete. I had to add this : https://github.com/facebook/react-native/issues/25294#issuecomment-503021597

Then the react-native-fs thing pops up that led me here, after trying to downgrade / upgrade in every react-native version I decided to tackle the problem at the source : if the .NonNull symbol was not found, let's find why but then this led to randomly trying package names till I found the .annotation prop which I found on the androidx package.

Then I removed the import android.support.annotation.Nullable; L11 from RNFSManager.java file and replaced it with : import androidx.annotation.Nullable; (this symbol was not greyed out / red like the previous one).

And then the error disappeared for the react-native-fs package but appeared on several other non-related packages which I managed to fix by doing the same thing.

Hope it helps someone.

EDIT :

Or simply delete all of the annotation found in your packages and it will works (delete the import NonNull/Nullable and where it is used ('@\NonNull' / '@\Nullable')

@maieonbrix Great! Thank you for the detailed explanation! I'm also having this issue after updating to 0.59.9. I'll probably be doing the same with some of dependencies. Could you create a PR for the change you made? That way others can pull your update.

React Native is migrating to androidx and all packages will need to make the change.
https://github.com/react-native-community/discussions-and-proposals/issues/129

@maieonbrix I created a PR. Let me know if you'd like me to take it down so you can submit your own.
https://github.com/itinance/react-native-fs/pull/691

thanks @maieonbrix your solution worked for me

i am also struggling with androidx update thing. till now
can you help me with

do have to update all node packages like react-native-fcm, react-native-fc...etc ???

i want a simple solution

I think you need indeed to update each of your packages, the simplest solution right now is just to delete the import and the annotation since it is just an annotation. told by @mikehardy here : https://github.com/itinance/react-native-fs/pull/691#issuecomment-504562995

@maieonbrix I tried doing your method and it's still throwing an RNFSManager.java uses or overrides a deprecated API

btw, my react-native version is 0.60.0 and my react-native-fs is 2.13.3

@darsodango you need to remove both the imports and the annotation here : https://github.com/itinance/react-native-fs/blob/v2.13.3/android/src/main/java/com/rnfs/RNFSManager.java#L624 (delete both import android.support.annotation.Nullable; and the @Nullable).

If this doesn't work then it's a new issue so open a new one, copy past the full error and I'll gladly try to help.

Anyone else still getting this error? I've tried all suggested fixes/hacks, nothing is working. I've tried various version of RNFS from "2.13.2" to "2.14.0" and now "2.15.2".

Reads:

"/node_modules/react-native-fs/android/src/main/java/com/rnfs/RNFSManager.java:
uses or overrides a deprecated API.
Recompile with -Xlint:deprecation for details."

"react": "16.6.3",
"react-native": "0.59.2",
"react-native-fs": "2.15.2",

@darsodango you need to remove both the imports and the annotation here : https://github.com/itinance/react-native-fs/blob/v2.13.3/android/src/main/java/com/rnfs/RNFSManager.java#L624 (delete both import android.support.annotation.Nullable; and the @Nullable).

If this doesn't work then it's a new issue so open a new one, copy past the full error and I'll gladly try to help.

i am facing an issue something like that but cann't find solution .Can you help me out ?

I'm getting this error inside a CI/CD application. I can't edit node_modules. Does somebody have any alternative?

@juliojeronimo you need to use jetifier either in forward or reverse mode depending on if you are using AndroidX or trying to remain on the support libraries. It will edit node_modules, if that is a hard constraint you need to talk with the people that made it in order to relax the constraint, as a practical matter.

Was this page helpful?
0 / 5 - 0 ratings