expo: Network request failed android (emulator and device)

๐Ÿ› 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.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 23 (6 by maintainers)

Most upvoted comments

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.

This is fixed for me when I deploy endpoint with https

I have the same issue both on Android device and iOS Simulator, steps to reproduce: https://docs.expo.io/versions/latest/guides/using-clojurescript/

Try this: https://github.com/seantempesta/expo-cljs-template/issues/84