eas build with axios resulting "Network Error" But works with expo build .

i’ve built a simple application on the managed workflow SDK 41 and i’m getting an error that i think it’s from axios .

when i use expo build:android the standalone works fine and i get an alert “User exists” , but when i use eas build i get the “Network error” on an axios get request . the request error is always fired , as you can see on the images below .

expo build : android

eas build -p android --profile preview

App.js

import React, { useState, useEffect } from "react";
import {
  Text,
  View,
  StyleSheet,
  KeyboardAvoidingView,
  Platform,
 
} from "react-native";
import {
  widthPercentageToDP as wd,
  heightPercentageToDP as hd,
} from "react-native-responsive-screen";
import { RFPercentage, RFValue } from "react-native-responsive-fontsize";
import axios from "axios";
import Colors from "./constants/Colors";

import ValidatePhone from "./helpers/validate-phone";

import LottieView from "lottie-react-native";

const SignIn = (props) => {




  const checkIfChauffeurtExist = async () => {
    //  setStep("loading");
    axios
      .post("http://135.181.38.97:8080/api/checkdriveruserid/", {
        username: 540142833,
      })
      .then(async function (response) {
        if (response.data == true) {
          alert("User exists");
        
        } else {
          alert("User exists pas ");

          //  setStep("initial");
        }
      })
      .catch(function (error) {
        alert(error);

        //setStep("initial");
      })
      .then(function () {
        // always executed
      });
  };
  checkIfChauffeurtExist();

  return (
    <KeyboardAvoidingView
      behavior={Platform.OS === "ios" ? "padding" : null}
      style={{ flex: 1 }}
    >
 

      {/* Second Step*/}
     
        <View style={styles.animationContainer}>
          <LottieView
            autoPlay={true}
            style={{
              width: 280,
              height: 280,
              backgroundColor: "#fff",
            }}
            source={require("./charging-teranga.json")}
          />
        </View>
      
    </KeyboardAvoidingView>
  );
};

SignIn.navigationOptions = (navData) => {
  return {
    headerShown: false,
  };
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },

  container1: {
    flexDirection: "column",
    paddingHorizontal: 24,
    paddingTop: 30,
    justifyContent: "center",
    alignItems: "center",
    flex: 1,
    backgroundColor: "white",
  },
  textInputContainer: {
    flexDirection: "row",
    borderRadius: 10,
    backgroundColor: "white",
    alignItems: "center",
    paddingHorizontal: 15,
    shadowColor: "#000",
    shadowOffset: {
      width: 0,
      height: 2,
    },
    shadowOpacity: 0.25,
    shadowRadius: 3.84,

    elevation: 5,
    marginBottom: 15,
  },
  motdepasse: {
    marginTop: 10,
    fontSize: RFValue(14),
  },

  textInput: {
    fontSize: RFValue(19),

    width: wd(70),
  },

  minitextInput: {
    height: RFValue(45),
    paddingLeft: 10,
    fontSize: RFValue(15),
  },

  veuillez: {
    fontSize: RFValue(16),

    textAlign: "center",
    width: "80%",

    marginBottom: "7%",
    color: Colors.dark,
  },
  sendSmsButton: {
    shadowColor: "#000",
    shadowOffset: {
      width: 0,
      height: 2,
    },
    shadowOpacity: 0.25,
    shadowRadius: 3.84,

    elevation: 5,
    backgroundColor: Colors.primary,
    width: "79%",
    height: RFValue(45),
    borderRadius: 10,
    justifyContent: "center",
    alignItems: "center",
    marginVertical: 7,
  },

  welcome: {
    fontSize: RFValue(25),
    color: "grey",
  },
  animationContainer: {
    backgroundColor: "#fff",
    alignItems: "center",
    justifyContent: "center",
    flex: 1,
  },
});

export default SignIn;

packages.json

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "axios": "^0.21.1",
    "expo": "~41.0.1",
    "expo-status-bar": "~1.0.4",
    "lottie-react-native": "3.5.0",
    "react": "16.13.1",
    "react-dom": "16.13.1",
    "react-native": "https://github.com/expo/react-native/archive/sdk-41.0.0.tar.gz",
    "react-native-paper": "^4.9.1",
    "react-native-responsive-fontsize": "^0.5.0",
    "react-native-responsive-screen": "^1.4.2",
    "react-native-svg": "12.1.0",
    "react-native-web": "~0.13.12"
  },
  "devDependencies": {
    "@babel/core": "^7.9.0"
  },
  "private": true
}

eas.json

{
  "builds": {
    "android": {
      "release": {
        "workflow": "managed",
        "buildType": "apk"
      },
      "preview": {
        "workflow": "managed",
        "buildType": "apk"
      }
    }
  }
}

Is there something that i’m missing ?? please help

Hey @islam01, I’m a little confused based on your screenshots. Based on the expo welcome menu it looks like your first screenshot corresponding to expo build is being run in the Expo Go app (meaning you’ve opened a published experience)? Can you try opening the standalone apk and seeing if the same error/behavior occurs as with the eas build?

Cheers,
Adam

Thanks for the reply ,

On a standalone apk built with expo build works great , yes the screenshot is from Expo go , i just wanted to illustrate the expected result .

In fact it was a bigger project which Is already in production built with expo build , so i wanted to give EAS a try to reduce the app size .

When i got this error , i created a minimal project which i mentionned above to see if some libs caused this issue .

Try updating axios. Axios changelog:

  • Fixing ‘Network Error’ in react native android (#1487) There is a bug in react native Android platform when using get method. It will trigger a ‘Network Error’ when passing the requestData which is an empty string to request.send function. So if the requestData is an empty string we can set it to null as well to fix the bug.

Not sure why this is only failing now, maybe the axios version changed in your project between builds.

Thanks ,

I checked again , i have the last version 0.21.1 installed . rebuilt my project with eas build , same error is occuring , can eas build service change the axios version anyhow ?

I don’t believe so, maybe you’ll have better luck debugging the app locally by running expo run:android which generates all of the code the same way managed EAS Build does.