- Notifications
You must be signed in to change notification settings - Fork793
Trouble Shooting
- How to remove files from Android's default apps?
- Failed to execute 'readAsText' on 'FileReader'
- version 0.7.0+ does not work with react-native 0.27 (Android)
- App crash on start (Android)
- RNFetchBlob.fetch is not a function
- Unknown type name 'namespace' (IOS)
- Could not send any HTTP request except localhost (IOS)
- Could not compile on IOS
- Undefined is not an object (evaluating 'RNFetchBlob.DocumentDir')
- How to access files from assets
- fs.readStream is freezing JS thread
- Firebase login and other API calls no response after replace the XMLHttpRequest
- How to remove files created by Download Manager?
When a file is downloaded by Android Download Manager or scanned byfs.scanFile, it will be added to Android'sMedia Content Database so that it becomes visible in default apps (for example, Downloads and Gallery).
Upon removing the file, you have to applyfs.scanFile again on the file's path after deleting it, otherwise, the user will still see the file in those apps but unable to interact with them.
Since we are not implementing FileReader polyfill, you might run into this error in some cases.
If you're facing this problem with Blob polyfill inDebug Mode, try replacewindow.fetch withfetch replacement should fix it.
On 0.7.5, we have fixed Android OkHttp dependency issue on pre 0.28 projects excepted 0.27, 0.29.0, and 0.29.1. For 0.29.0 and 0.29.1 it's becausernpm link is broken in these versions, you may need to manually link Android package. It is recommended to upgrade you project if possible
$ react-native upgradeAfter the project upgraded, runrnpm link again.
This might because rnpm added multiplenew RNFetchBlobPacket() to yourMainApplication.java, the error message may looks like
java.lang.RuntimeException: Unable to start activity ComponentInfo ...Try to remove duplicatednew RNFetchBlobPacket() inMainApplication.java
This usually means that you're using ES5, you userequire('rn-fetch-blob') instead ofimport RNFetchBlob from 'rn-fetch-blob'. There's a very very good explanation onStackOverflow
The issue is you are using ES5 style require statements with a library written against ES6/ES2015. You have two options:
ES5:
var RNFetchBlob = require('rn-fetch-blob').default
ES6:
import RNFetchBlob from 'rn-fetch-blob'
by rmevans9@StackOverflow
This usually happens when the RNFetchBlob deployment target version is incorrect, it is fixed in0.7.1, you may upgrade your package to0.7.1 or manually fix it by following steps
Open.xcodeproj of your app and open theLibraries folder in left side tree view

Find project -> RNFetchBlob, click on it

Change the deployment target to8.0

Rebuild the project again
reference fromofficial document
App Transport Security is a security feature, added in iOS 9, that rejects all HTTP requests that are not sent over HTTPS. This can result in HTTP traffic being blocked, including the developer React Native server.
ATS is disabled by default in projects generated using the React Native CLI in order to make development easier. You should re-enable ATS prior to building your app for production by removing the NSAllowsArbitraryLoads entry from your Info.plist file in the ios/ folder.
To learn more about how to configure ATS on your own Xcode projects, seethis post on ATS.
If you're having problem when compiling IOS project, and the error looks like
ARC forbids synthesizing a property of an Objective-C ..You should try to upgrade Xcode to version >=7.3 or upgradern-fetch-blob to latest version, because we have already solved this problem.
see also#31
Error messages likeXXX is undefined,could not found RNFetchBlob ... usually because the package does not properly installed, there're some closed issues about installation problems#51,#12,#30
After0.6.2 you can access files inside app bundle by simply adding the prefixbundle-assets:// before the filename. You can also wrap the filename byfs.asset API. For example, upload a file from assets
RNFetchBlob.fetch('POST','http://myupload.com/upload',{'Content-Type' :'application/octet-stream'},RNFetchBlob.wrap(RNFetchBlob.fs.asset('my-asset.png'))).then((resp)=>{ ...})
Generally you can access the file as usual once you wrap the file name byfs.asset, but keep in mind, assets files arereadonly, so you are not be able to remove, or change them.
On Android, files should be placed in the android/app/src/main/assets/ folder or a subfolder of this directory.The asset file must not be compressed in the APK. If the file type is not one automatically excluded from compression by aapt, the extension type can be added to the aaptOptions in build.gradle as such:
aaptOptions { noCompress "txt", "json" }The compression state of the file in the APK can be verified by running
unzip -lv {app.apk}The columnmethod should indicate no compression.
By default,readStream uses a very small buffer (4kb), when the file is large, theonData events will likely becomes heavy overhead to JS thread, the solution is increase thebufferSize to reduce the amount of event, but keep in mind if the buffer size is too large (greater than heap limit), it will crash the app. For more discussion see#118.
This is caused by incorrect implementation in XMLHttpRequest polyfill, we've fixed this issue in0.9.6-beta.2, it should be fixed after you upgrade the package.
For the files downloaded by Download Manager, you will need to set the destination explicitly for ensuring the file will be created in an accessible location.
RNFetchBlob.config({addAndroidDownloads :{useDownloadManager :true,title :newDate().toLocaleString()+' - #236 test.png',// download manager will use this location instead.// keep in mind this `path` should be somewhere on external storage (like SDCardDir or DCIMDir)path :RNFetchBlob.fs.dirs.DCIMDir}}).fetch('GET',`${TEST_SERVER_URL}/public/github.png`)