Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to invoke virtual method 'java.lang.String java.io.File.getAbsolutePath()' on a null object reference #29

Closed
jgreen01su opened this issue Apr 26, 2021 · 2 comments · Fixed by #31

Comments

@jgreen01su
Copy link

"react-native": "^0.63.4",
"react-native-blob-util": "^0.13.6",

I'm seeing the following error on my android emulator SDK version 22 with no SDCard.

[Mon Apr 26 2021 15:02:20.360]  ERROR    Error: Exception in HostObject::get(propName:ReactNativeBlobUtil): java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.io.File.getAbsolutePath()' on a null object reference
[Mon Apr 26 2021 15:02:20.360]  ERROR    Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)
[Mon Apr 26 2021 15:02:20.370]  ERROR    Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)

It appears to be an issue with the code in ReactNativeBlobUtilFS.java file line 264 or 281 and I believe it's the same as this stackoverflow.
https://stackoverflow.com/a/20548378

@RonRadtke
Copy link
Owner

Which path are you trying to access?

@juanamd
Copy link

juanamd commented Apr 29, 2021

Having the same issue appear on several bug reports in production.
I'm accessing the DocumentDir, but idk if it is related exactly to that or just that if it happens to be the case where any of the externalFilesDir returns null.

The easiest solution would be to wrap everything on a try-catch and return an empty response here or reject the promise here.

But the better solution would be to check every getExternalFilesDir for a null value before calling getAbsolutePath() (java doesn't have optional chaining, right?) and return an empty value if its null.

RonRadtke added a commit that referenced this issue May 1, 2021
Add null checks to getExternalFilesDir calls
Fixes #29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants