Closed
Description
Please provide all the information requested. Issues that do not follow this format are likely to stall.
Description
After upgrading from 0.61.4 to 0.62.0 the app will not upload files anymore from Android (all other requests are working fine)
React Native version:
0.62.0
Steps To Reproduce
- Install a fresh ReactNative app via CLI
- Upload a file to the emulator
- Try to upload a file using
fetch
import Picker from "react-native-image-picker"
import {request, PERMISSIONS, RESULTS} from 'react-native-permissions';
class App extends React.Component {
async componentDidMount() {
try {
await request(PERMISSIONS.ANDROID.WRITE_EXTERNAL_STORAGE)
await Picker.launchImageLibrary({noData: true}, async (file) => {
try {
const body = new FormData()
body.append("file", { type: file.type, size: file.fileSize, uri: `file://${file.path}`, name: file.fileName })
const headers = { "content-type": "multipart/form-data", "accept": "application/json" }
const req = await fetch("ANY_SERVER/upload/image", {
method: "POST",
headers,
body
})
console.log(req.status)
} catch (e) {
console.log(e)
}
})
} catch (e) {
console.log(e)
}
}
render(){
return <View/>
}
}
Expected Results
The request should reach the server to upload the file
Snack, code example, screenshot, or link to a repository:
https://snack.expo.io/01W!bybf_
[Mon Apr 06 2020 21:29:18.704] LOG [TypeError: Network request failed]
Activity
carlezzo commentedon Apr 6, 2020
Same problem here!
adityamohta commentedon Apr 6, 2020
Same problem !! I am stuck on this issue from last 2 days! Searched almost everything..
HaidarZ commentedon Apr 6, 2020
You need to add this
uesCleartextTraffic="true"
to the AndroidManifest.xml file found inside the dir android/app/src/main/AndroidManifest.xmlAccording to docs
adityamohta commentedon Apr 6, 2020
I have tried it already. This is used when you are making request to a http server, but my server is running on https. It was running perfectly before upgrading to 0.62.
Something is wrong.
adityamohta commentedon Apr 6, 2020
All other requests are working perfectly. Only file uploads are not working anymore.
HaidarZ commentedon Apr 6, 2020
I faced too many issues when I tried upgrading to 0.62 even though I created a new app and moved my code into it. I rolled back to 0.61.5 till it gets stable :/
MateuszRostkowski commentedon Apr 7, 2020
I am facing the same issue, for RN 0.62.0 and 0.62.1 throws this error:
Network request filed
.All requests work except for the image post
adityamohta commentedon Apr 7, 2020
I moved back to 0.61.5 :( No other choice left for now. If anyone needs help in downgrading to 0.61.5, refer to react-native-upgrade-helper.
preko96 commentedon Apr 7, 2020
Same happens here!
alfianwahid commentedon Apr 7, 2020
I faced same issue, it happens in Android, but works well in IOS.
I guess this issue about Flipper Network.
For while, I commented
initializeFlipper(this, getReactNativeHost().getReactInstanceManager())
in this file
/android/app/src/main/java/com/{your_project}/MainApplication.java
trglairnarra commentedon Apr 8, 2020
This issue occurs also on my end, and guess what it is only occurring in debug mode. Tried building in internalRelease and it works fine. I guess it is because of the auto/fast reload in debug mode which applies some flipper communication which seems to be related in this issue..
Another issue here is that there is no error in android logcat.. I've also spent some days researching how to fix this issue still no luck.
abumostafa commentedon Apr 8, 2020
Whoever is still struggling with this issue. it's happening because of Flipper network plugin.
I disabled it and things work just fine.
My workaround to make this work is commenting out line number 43
in this file
android/app/src/debug/java/com/**/ReactNativeFlipper.java
safaiyeh commentedon Apr 8, 2020
Thanks for the issue @abumostafa. Does this occur in a fresh React Native template out of the box? If so this should be looked at otherwise feel free to close it.
353 remaining items