joltup / rn-fetch-blob

A project committed to making file access and data transfer easier, efficient for React Native developers.
MIT License
2.81k stars 772 forks source link

Android Error after installing rn-fetch-blob #570

Closed luccadumas closed 4 years ago

luccadumas commented 4 years ago

react-native-cli: 2.0.1 react-native: 0.61.5 rn-fetch-blob: 0.12.0

On IOS, lib worked fine, but on Android this error is coming up:

I'd appreciate if you could help me.

image

`> Task :rn-fetch-blob:compileReleaseJavaWithJavac FAILED /Users/etros/Documents/workspace/sp-react-native/node_modules/rn-fetch-blob/android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java:601: error: unreported exception IOException; must be caught or declared to be thrown callback.invoke("Unexpected FileStorage response file: " + responseBody.string(), null); ^ 1 error

FAILURE: Build failed with an exception.

BUILD FAILED in 3m 44s `

luccadumas commented 4 years ago

It works for me.

-> I uninstalled lib -> Removed node_modules (rm -rf node_modules) -> I installed node_modules again -> I installed the lib -> I followed the tutorial for the new version of lib (https://github.com/joltup/rn-fetch-blob) -> I manually linked the package (https://github.com/wkh237/react-native-fetch-blob/wiki/Manually-Link-Package#user-content-link-android-package) -> I manually added permissions for Android

async function permissionsAndroid() { try { const granted = await PermissionsAndroid.request( PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE ); openPDF(); //call to the function of opening the PDF similar to what you do in the video } catch (err) { console.warn(err); } }

I think the lib link was missing manually, I had tried it once, but there was already a lot of trash in the cache, so I decided to uninstall everything and do the whole process again.

Now it works for me! :D