eas update not working as expected

So after getting some feedback/guidance on how eas update works to handle over the air updates, I decided to test this with a sample app. I build a new default react native app with the following command: npx create-expo-app my-app.

I then configured it and added this to my eas.json:

    "test": {
      "channel": "one",
      "android": {
        "buildType": "apk"
      },
      ios: {
        "enterpriseProvisioning": "universal",
        resourceClass: "m1-medium"
      }
    }

I then ran:

eas build --profile test --platform all

This worked as expected and this generated builds for both Android and iOS.

I then downloaded and installed the test app on my Android.

Then, to test pushing an update of JavaScript code, I made a small test update, changing the version number on some text:

> export default function App() {
>   return (
>     <View style={styles.container}>
>       <Text>Welcome to Test App!</Text>
>       <Text>Version 1.0.1</Text> // Iterated from 1.0.0 to 1.0.1 here
>       <StatusBar style='auto' />
>     </View>
>   );
> }

I saved this and then ran:

eas update --branch one --platform all

My understanding is this is all that’s necessary to have the updates pushed to the app on my device, and that since my targeted channel is one, a branch automatically gets assigned to this as well, so targeting --branch one to send the update “over the air” should work here.

However, even though I’ve restarted my phone several times, and re-opened this test app each time, I never see the change in text rendered to the screen. What am I missing here?

Hi @darrenbrett, I’d suggest following our debugging guide here to debug what would be the underlying issue. You can also read the logs using the Updates.readLogEntriesAsync() method from the expo-updates package.

It can also be an issue related to environment variables, but with the information you have shared, I’m not sure if you are using them or not in your project.

So, to clarify, since you didn’t state this specifically, from your understanding the procedure I followed was the correct one to manage the over the air update, based on my original build command, yes?

Also, we don’t use environment variables in the eas.json, so really not sure what the issue would be if the update command I used looked correct.

That looks about right to me.

Is it possible your device couldn’t reach the update URL specified in app.json?

I don’t see why not, considering it was able to access it during the build. Do you see any issues here with my app.json file?

{
  "expo": {
    "name": "my-app",
    "slug": "my-app",
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/icon.png",
    "userInterfaceStyle": "light",
    "splash": {
      "image": "./assets/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "updates": {
      "fallbackToCacheTimeout": 0,
      "url": "https://u.expo.dev/4d47d235-4d55-4e36-beb6-cb7f39b6eb1e"
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "ios": {
      "supportsTablet": true,
      "bundleIdentifier": "com.some.myapp"
    },
    "android": {
      "adaptiveIcon": {
        "foregroundImage": "./assets/adaptive-icon.png",
        "backgroundColor": "#FFFFFF"
      },
      "package": "com.some.myapp"
    },
    "web": {
      "favicon": "./assets/favicon.png"
    },
    "extra": {
      "eas": {
        "projectId": "4d47d235-4d55-4e36-beb6-cb7f39b6eb1e"
      }
    },
    "runtimeVersion": {
      "policy": "appVersion"
    }
  }
}

By “your device” I meant your Android phone.

Anyway, maybe try the code from here that will allow you to press a button to get the update instead of having to restart the app multiple times:

https://docs.expo.dev/eas-update/debug-updates/#in-app-debugging

If that doesn’t help, try intercepting network traffic (also mentioned on the EAS Update Debugging page or here: GitHub - LabCIF-Tutorials/Tutorial-AndroidNetworkInterception: How to intercept network trafic on Android)

2 Likes

Thanks, will look into that. I appreciate your help.

Yes, the process you are following seems good to me, and that’s why I shared the link to the debugging guide earlier. Let me know how it goes.

1 Like

Looking into this.

Hi

By the way, by default the app will check for an update when it’s opened, but it won’t load the updated bundle until the next time it’s opened. So that’s why it needs to be closed and opened twice before updates normally show.

If you want the updates to be more transparent, you can in addition (or instead) have a way for the user to click a button to check for updates and then another button to restart the app in order to load the updated bundle.

Also, if say your users don’t close and open the app often enough, and you don’t want them to have to check manually, you could get the app to check automatically every now and then (e.g. when the app comes to the foreground) and if there is an update you can show a Floating Action Button to prompt the user to restart the app so that the new bundle can be loaded.

In one app I did something like the last paragraph, except I hooked it up to clicking any of the buttons on the home screen. In addition I kept track of when the last update check was and only checked again if it had been 4 hours since the last check. If I were to do it again I’d do the update check based on the app coming to the foreground instead.

1 Like

In the end I got this to work in both the testing app I tried, and my actual app with the following command:

eas update --branch next --platform all --message “iterate to 1.0.2”

To make it check for updates I handled it like so:

import * as Updates from 'expo-updates';

class LoginScreen extends React.PureComponent {
  constructor() {
    super();
  }

  async componentDidMount() {
    await this.onFetchUpdateAsync();
  }

  onFetchUpdateAsync = async () => {
    try {
      const update = await Updates.checkForUpdateAsync();

      if (update.isAvailable) {
        await Updates.fetchUpdateAsync();
        await Updates.reloadAsync();
      }
    } catch (error) {
      alert(`Error fetching latest Expo update: ${error}`);
    }
  };

   render() {
       return (...)
   }
}
2 Likes

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