-
Notifications
You must be signed in to change notification settings - Fork 774
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
Class Cast exception #490
Comments
Change |
@z384647062 I have same issue, but don't use any RNFetchBlob.fs.dirs.MusicDir in app. I use RNFetchBlob.fs.dirs.DocumentDir everywhere. |
Question to maintainers, Is it possible to review this issue please? |
@Traviskn Hello, I have checked this issues in 0.10.16 and it is not reproducible! |
Any ideas guys? |
This worked in my case too :) |
Relates to recent PR #530 that is going to catch it and return back. |
I am getting the same error on Mac OS X with Android simulator (API 29 Google Play):
Error:
Version: 0.12.0 |
same error in Xiaomi with android 9 and MIUI Global 11.3.4. instead everything works normally for example with pdf ... any help? |
I have the same issue on Pixel 3 and,
|
I am having this issue too. If I catch the exception, like in PR #530, then it will just fail silently and not download and save the file. I am trying to download lots of files at once. They are for the most part slippy map tiles, in other words tiny png files. I slice the list of files in portions, so I do for example 20 at a time with Noticeably, the So, to be clear, I have an array of promises, about 800 of them, like this:
I then do This happens on the emulator, on a OnePlus 6 and on a Sony XZ1. It is also worth mentioning that the previous version of the app, which was built with Cordova, also had a similar issue on Android. |
Although downgrading to
|
@Traviskn Hello, any ideas how to fix this issue? Can we revert it and publish new npm package? |
Is this library still maintained? Looks like no... |
same ussue ((( help wanted |
@Traviskn Is it possible to revert PR related to this issue? We are blocked currently in out project with this issue |
I am having the same issue in production app. |
Any Update on this issue??? |
I think the reason this error occurred is related to Android 10's file access policy. So I temporaryly fixed it by add <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.android.example">
...
<application
android:name="com.android.example.MainApplication"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:requestLegacyExternalStorage="true"
android:theme="@style/AppTheme">
...
</application>
</manifest> |
@nguyenhoanglam it does not work in my case, and i get the error also for android 9 |
@nguyenhoanglam Worked on Android 10, thanks. |
I was getting this error too in some Android devices. Some of the users of my app have denied the app permission to manage files, so when trying to downloading something the app would just crash. Checking the permissions before downloading have fixed this issue for me Edit: While this fixed the issue for the majority of my users, there are some cases where the problem persists, even when the permissions are correctly set. I will try to contact the user and send him a custom build using expo filesystem. |
Commenting here even though I can see PR #530 has been merged. I think that PR suppresses the crash but does not address the underlying cause, which is the custom OkHttp interceptor that is installed in This interceptor is responsible for wrapping the response body in an instance of
I have been able to reliably replicate the issue by programatically causing |
This issue exists because the exported rn-fetch-blob/android/src/main/java/com/RNFetchBlob/RNFetchBlobFS.java Lines 250 to 262 in 9110ef2
|
I also had this problem in Android 8.1.0 Nexus 5X. Attribute android:requestLegacyExternalStorage="true" didn't fix it but downgrading to 0.10.16 solved the issue. thanks @oleksandr-dziuban |
If you install from the master branch using |
I solved it by following @nguyenhoanglam 's answer for android above 10, and requesting permission for android above 6. Android >= 10add Android >= 6request permission before fetch const requestExternalStoragePermissions = async () => {
const read = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE,
);
const write = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
);
return (
read === PermissionsAndroid.RESULTS.GRANTED &&
write === PermissionsAndroid.RESULTS.GRANTED
);
}; |
I solved this problem by modifying rn-fetch-blob and saving those changes permanently using patch-package.
|
This lib not maintained. I used react-native-blob-util properly maintained. It's helped me to fix issues with Class Cast exception. |
please provide the version of installed library and RN project.
React native: 0.60.4
rnFetchBlob: 0.11.2
a sample code snippet/repository is very helpful to spotting the problem.
We are not able to reproduce crash. Many of app users are facing issue.
rnFetchBlob is crashing with the below exception. We have got this exception in bugsnag
java.lang.ClassCastException okhttp3.internal.http.RealResponseBody cannot be cast to com.RNFetchBlob.Response.RNFetchBlobFileResp
RNFetchBlobReq.java:544 com.RNFetchBlob.RNFetchBlobReq.done
RNFetchBlobReq.java:67 com.RNFetchBlob.RNFetchBlobReq.access$100
RNFetchBlobReq.java:445 com.RNFetchBlob.RNFetchBlobReq$3.onResponse
RealCall.java:174 okhttp3.RealCall$AsyncCall.execute
NamedRunnable.java:32 okhttp3.internal.NamedRunnable.run
ThreadPoolExecutor.java:1113 java.util.concurrent.ThreadPoolExecutor.runWorker
ThreadPoolExecutor.java:588 java.util.concurrent.ThreadPoolExecutor$Worker.run
Thread.java:818 java.lang.Thread.run
The text was updated successfully, but these errors were encountered: