Network Error on Android standalone app only

SDK Version: 44
Platforms(Android/iOS/web/all): Android

I have recently updated an app from about SDK version 38. After this everything seemed to be working as it should in both the Android Emulator and the IOS Simulator. I built out standalone apps for both IOS and Android. The IOS version works entirely as it should, but in the Android no axios requests seem to work. The error I get reported in Sentry is Network Error. I have tried to follow the solutions presented in here I cant post/get request to api from android but it works perfectly in ios. Api working perfectly on android browser. Note: API'S Certificate provided by Let's Encrypt · Issue #12016 · expo/expo · GitHub

I also checked out Fetch Fails with "Network request failed" only on Android · Issue #16451 · expo/expo · GitHub but it is not something to do with FormData, as it happens on all requests.

The SSL certificates on the server are supposed to be valid.

This is the request function we have. I have tried to separate out the function to entirely remove the body as well, and not just have it undefined, but that did not help either.

const request = async ({ endpoint, data, method = RequestMethods.GET, param = '', query = '' }: Endpoints[number]): Promise<any> => {
  const url = `${ baseUrl }${ endpoint }${ param ? '/' + param : '' }${ query ? `?${ query }` : '' }`;

  const body = data ? JSON.stringify(data) : undefined;
  const headers = {
    'Content-Type': 'application/json; charset=utf-8',
    'Accept': 'application/json',
  };

  try {
    const response = await axios({
      url,
      method,
      data: body,
      headers,
    });
    
    return response;
  } catch (error) {
    throw error.response || error;
  }
};

I am at a loss here, any ideas?

Hey @metiniveo, if you haven’t already, can you try to reproduce this in a vanilla React Native project? It’ll be useful to know if this is expo-specific or not.

Cheers,
Adam

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.