question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Network request failed android (emulator and device)

See original GitHub issue

🐛 Bug Report

Environment

Expo CLI 3.0.10 environment info: System: OS: macOS 10.14.5 Shell: 5.3 - /bin/zsh Binaries: Node: 8.9.0 - ~/.nvm/versions/node/v8.9.0/bin/node Yarn: 1.12.3 - /usr/local/bin/yarn npm: 5.5.1 - ~/.nvm/versions/node/v8.9.0/bin/npm IDEs: Android Studio: 3.4 AI-183.6156.11.34.5692245 Xcode: 10.3/10G8 - /usr/bin/xcodebuild npmPackages: expo: ^32.0.0 => 32.0.6 react: 16.5.0 => 16.5.0 react-native: https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz => 0.57.1 react-navigation: 2.3.1 => 2.3.1 npmGlobalPackages: expo-cli: 3.0.10

Android device and emulator

Steps to Reproduce

So I’m really new to expo and don’t know how all your magic works, and I’m having an error like this:

[Unhandled promise rejection: TypeError: Network request failed]
- node_modules/react-native/Libraries/vendor/core/whatwg-fetch.js:504:29 in onerror
- node_modules/event-target-shim/lib/event-target.js:172:43 in dispatchEvent
- ... 8 more stack frames from framework internals

So I’m having this error on both emulator and device build - TypeError: Network request I’ve found a lot of issues related to problem like this, but the solutions did not really help.

Here is how I’m making request:

const response = await fetch(`${urls.apiBase}/auth/logout`, {
    ...fetchParams,
    method: 'POST',
    headers: {
      'Content-Type': 'application/json; charset=utf-8',
      Authorization: `bearer ${token}`,
    },
    body: JSON.stringify({}),
  });

and here is my app.json:

{
  "expo": {
    "name": "CommonSpace",
    "description": "CommonSpace is a prototype built by Sidewalk Labs to explore how technology might enable the study of public life. It allows space managers and community groups to study activity in their public spaces in accordance with the Public Life Data Protocol.",
    "githubUrl": "https://github.com/sidewalklabs/commonspace",
    "primaryColor": "#4A90E2",
    "slug": "CommonSpace",
    "privacy": "unlisted",
    "sdkVersion": "32.0.0",
    "scheme": "commonspace",
    "platforms": [
      "ios",
      "android"
    ],
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/images/AppIcon.png",
    "splash": {
      "image": "./assets/images/CS_LaunchImage.png",
      "resizeMode": "contain"
    },
    "updates": {
      "enabled": false
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "ios": {
      "bundleIdentifier": "com.commonspace.commonspace",
      "supportsTablet": true,
      "config": {
        "googleMapsApiKey": "GENERATE_A_MAPS_KEY",
        "googleSignIn": {
          "reservedClientId": "GENERATE_A_RESERVEDCLIENTID"
        }
      },
      "infoPlist": {
        "NSLocationWhenInUseUsageDescription": "Your location is used to show you where you are on a map of your assigned survey zone. Your location is never stored or transmitted off your device."
      }
    },
    "android": {
      "package": "com.commonspace.commonspace",
      "versionCode": 1,
      "permissions": [
        "ACCESS_COARSE_LOCATION",
        "ACCESS_FINE_LOCATION",
        "CAMERA"
      ],
      "config": {
        "googleMaps": {
          "apiKey": "GENERATE_A_MAPS_KEY"
        },
        "googleSignIn": {
          "apiKey": "GENERATE_AN_AUTH_KEY",
          "certificateHash": "GENERATE_A_CERTIFICATE_HASH"
        }
      }
    },
    "extra": {
      "googleAuthClientId": {
        "expo": {
          "android": "603386649315-vp4revvrcgrcjme51ebuhbkbspl048l9.apps.googleusercontent.com",
          "ios": "603386649315-vp4revvrcgrcjme51ebuhbkbspl048l9.apps.googleusercontent.com"
        },
        "standalone": {
          "android": "GENERATE_AN_AUTH_KEY",
          "ios": "GENERATE_AN_AUTH_KEY"
        },
        "guest": {
          "android": "GENERATE_AN_AUTH_KEY",
          "ios": "GENERATE_AN_AUTH_KEY"
        }
      }
    }
  }
}

Also, I know that there is some issue like this - https://github.com/expo/expo/issues/1606 but did not find solution there.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:23 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
nfabacuscommented, May 10, 2020

yes, I also have the same issue only for android simulator. web and ios simulator work fine. For the time being for android simulator, I am using ngrok to access localhost via https.

2reactions
onlyargoncommented, Nov 2, 2019

This is fixed for me when I deploy endpoint with https

Read more comments on GitHub >

github_iconTop Results From Across the Web

React-Native Network request failed on Android Emulator API ...
I'm seeing this on a physical device running Android Pie / Android API Level 28. Also saw this on the iOS Simulator. This...
Read more >
Network request failed Android - Stack Overflow
Check your Android emulator options panel adjacent to your emulator, in that you will have more options then go to cellular and check...
Read more >
Network request Failed. Linux with Android-Studio, ExpoGo ...
I'm running pop_os(Linux) and using expoGo with Metro bundler and Android-Studio emulator...I keep getting. Network request failed at ...
Read more >
Network Request Failed/Network Error in React Native using ...
When making an HTTP Request with React Native, there is some kind of conflict because your Android app is run on an emulator...
Read more >
Set up Android Emulator networking
Each instance of the emulator runs behind a virtual router or firewall service that isolates it from your development machine network ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found