-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fetch not working on Android 9 API 28 #24627
Comments
Same here. There is an exception called "NoSuchKeyException" when use fetch api (it's only as release). |
I tried now to change fetch to axios, same error. I believe that is an Android security configuration missing ou somenthing like. |
It seems that the solution for now is to rollback my RN project (from last version .59.5) to .58 :/, but i'm using hooks :( |
Same issue here, have you found any better solutions by any chance? I'm running RN 0.58.3 for reference |
See this #24361 |
On latest RN 0.59.x, all http connections should be doable in debug apps, and https should only be enforced in release apps. If issue is related to I don't know about Also version numbers reported here by multiple people are conflicting, please clearly write |
You need to use "https" when fetching something. Installing SSL certificate and enabling https link solved my issue. (I did try Android 9.0, axios is working, fetch is working.) |
@mrkacan Many people use |
Are you able to access the api from chrome browser? localhost on Android emulator is not the same as the host. You might need to do a adb reverse for it to work |
Hi for testing purposes, we are using http for fetch data to our test physical mobile devices, if react-native block this capability, in our test environments we should install more than one ssl certificate and it made complex routines for internal tests. it doesn't make sense to prevent using http in development level, some use cases and some business may use http, without any security becase the net work is private and ssl encapsulation will made the request/response too slow. i think this rule must be add in devoploment and business level not in development languages level. Regards. |
Hi All, I found a work around solution for Http (non HTTPS) fetch :
|
@mohsenomidi |
That worked for me too. Thanks! @mohsenomidi I was having the same problem OP had, but using axios and having just updated my cordova android platform to the newest one. |
@mohsenomidi That worked for me too :) |
@mohsenomidi You save my life today, Thanks |
Thanks for your help
|
is the issue solved for https?? Trying to fetch data from remote server via api. I have already went through various links, and many people have posted same problem but none of them had ample solution that works. While some people were not able to access localhost via api-call but it was resolved using IP address of system. But in my scenario I am trying to access remote host. Also domain name cannot be used in my scenario, so need a solution using (ip) in fetch method=get. testlogin = https://10.209.7.115:8080/api/v1/ fetch(testingLogin, { TypeError: Network request failed info |
@amohit1315 your issue is not related to this case you are using HTTPS and have an issue, please open another case to report your problem, the workaround solution for http fetch only has been provided in my last comment. |
React-Native Version: 0.59.0
|
Seeing the same issue using HTTPS connections via Axios and Fetch, running on Android Pie API 28. Adding android:usesCleartextTraffic="true" to manifests does not resolve this issue. package.json dependencies: Axios and Fetch examples:
|
Hi Everyone, whoever is facing this problem. Stop using fetch. Install "'react-native-fetch-blob'" import it in your js file as import RNFetchBlob from 'react-native-fetch-blob'; Replace your original fetch as below code
trust: true avoids checking for certificates. Good luck. Comment if you found it useful or not. |
This is unfortunately quite a dangerous workaround that I would not recommend. Your app should always be checking to ensure certificate are valid and not foraged. |
True I agree.... one should always configure certificates.... My scenario was tricky because my app required fetch info from remote host...there could be a thousand or many more and each will have separate certificate One should use this approach in desperate need only 😊 |
Add the code then clean Android gradlew then restart your code editor and
restart your pc or computer.....
…On Sun 6 Sep, 2020, 8:35 PM Lanre Adedara, ***@***.***> wrote:
@HIPHOPSANDY <https://github.com/HIPHOPSANDY> tried that already, didn't
work.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#24627 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AJJEGMZQGTKJHFPCPIUBPUDSEOQKBANCNFSM4HIW2UQA>
.
|
Same thing @HIPHOPSANDY |
Check the image try to implement your code ...
…On Sun 6 Sep, 2020, 9:02 PM Lanre Adedara, ***@***.***> wrote:
Same thing @HIPHOPSANDY <https://github.com/HIPHOPSANDY>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#24627 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AJJEGMZTIMSP7R5FQO5XA3TSEOTRRANCNFSM4HIW2UQA>
.
|
I'm not sure I understand that @HIPHOPSANDY |
Try to adding this permission at the top of the AndroidManifest.xml |
are you solved? |
yes dear, https instead of httpwork for meSent from my Samsung Galaxy smartphone.
-------- Original message --------From: HIPHOPSANDY <notifications@github.com> Date: 07/09/2020 12:29 (GMT+05:00) To: facebook/react-native <react-native@noreply.github.com> Cc: Muhammad Aamir Javed <blackprinceaj@gmail.com>, Comment <comment@noreply.github.com> Subject: Re: [facebook/react-native] Fetch not working on Android 9 API 28 (#24627)
are you solved?
—You are receiving this because you commented.Reply to this email directly, view it on GitHub, or unsubscribe.
|
This is my development environment.
I solved this problem as follows.
That's it! I hope this will help you out. |
Thanks. It worked for me. It was missing to disable the warning. |
Making the backend from http to https works fine But even after making to https I got an issue and at last I found that SSL was not configured properly https://www.digicert.com/help/ - U can check ssl configuration is done prorperly or not using this link |
Hi guys, after speding many hour to research about this issue i have this solution: Using ngrok to remote to your local development. So you need:
|
@gvsakhil thanks, that page helped me to identify some problems, which i hope are the reasons for the fetch not working in our application. no i am figuring out with some colleagues, how to solve the insecure ones. any helpful suggestions? |
i figured out my problem. at the end it was no problem with server and SSL. |
Let's encrypt users Yes, please use this. Even better is |
instead of trying local host use your android amulator ip address |
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
This issue was closed because it has been stalled for 7 days with no activity. |
I still can't get the API calls working on Android 9. On all other versions of Android works well. And I use cloudflare SSL certificate on my domain. So, not sure what is going on with Android 9. Any help would be appreciated. |
Hai Broooo you save my day! |
This worked for me on EXPO SDK 49: "plugins": [
[
"expo-build-properties",
{
"android": {
"usesCleartextTraffic": true
}
}
]
] |
|
not work for me |
🐛 Bug Report
Hello,
I'm having an Issue about a HTTP service (the error only in simulator with API 28 (Pie) environment). I already add the domain on react_native_config.xml and add the networkSecurityConfig on both Manifests.xml (debug and release) but still get the TypeError: Network request failed error:
I already try all this Issues: #23986, #23984
My info:
info
React Native Environment Info:
System:
OS: macOS 10.14.2
CPU: (8) x64 Intel(R) Core(TM) i7-3720QM CPU @ 2.60GHz
Memory: 318.58 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 11.8.0 - /usr/local/bin/node
Yarn: 1.13.0 - /usr/local/bin/yarn
npm: 6.9.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
Android SDK:
API Levels: 25, 26, 27, 28
Build Tools: 25.0.0, 25.0.1, 26.0.2, 27.0.3, 28.0.3
System Images: android-25 | Google APIs Intel x86 Atom, android-25 | Google APIs Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom
IDEs:
Android Studio: 3.3 AI-182.5107.16.33.5199772
Xcode: 10.2/10P91b - /usr/bin/xcodebuild
npmPackages:
react: 16.8.3 => 16.8.3
react-native: 0.59.0 => 0.59.0
npmGlobalPackages:
react-native-cli: 2.0.1
react-native-git-upgrade: 0.2.7
My react_native_config.xml:
localhost 10.0.2.2 10.0.3.2acolhebrasil.com.br
My fetch:
fetch(baseURLAPI + action, {
method: method,
headers: headers,
body: bodyObj ? JSON.stringify(bodyObj) : null
}).then((response) => {
console.log(response)
if(response.ok){
return response.json();
}
throw new Error(response.text());
})
.then((responseJson) => {
console.log(responseJson)
if(callbackSuccess){
return callbackSuccess(responseJson);
}
})
.catch((error) => {
console.log(error)
if(callbackError){
return callbackError(error);
}
});
My API: http://acolhebrasil.com.br/Sistema/api/#/
Console:
TypeError: Network request failed
at XMLHttpRequest.xhr.onerror (ReactNativeRenderer-dev.js:3731)
at XMLHttpRequest.dispatchEvent (ReactNativeRenderer-dev.js:10394)
at XMLHttpRequest.setReadyState (ReactNativeRenderer-dev.js:10127)
at XMLHttpRequest.__didCompleteResponse (ReactNativeRenderer-dev.js:9895)
at ReactNativeRenderer-dev.js:10051
at RCTDeviceEventEmitter.emit (blob:http://localhost:8081/9854a9b9-407d-4571-8675-e6fadd170803:3282)
at MessageQueue.__callFunction (ReactNativeART.js:13)
at blob:http://localhost:8081/9854a9b9-407d-4571-8675-e6fadd170803:2336
at MessageQueue.__guard (ReactNativeART.js:10)
at MessageQueue.callFunctionReturnFlushedQueue (blob:http://localhost:8081/9854a9b9-407d-4571-8675-e6fadd170803:2335)
The text was updated successfully, but these errors were encountered: