Versioning of Android React Native Apps with expo-updates

2.5k views Asked by At

I am trying to figure out how to configure expo-updates for OTA updates in my React Native app (for Android). If I understand correctly, I need a way of versioning the builds so that the right updates go to the right builds of the app that people may have installed on their devices. This can be achieved in two ways (note that I am using expo-cli to manage my workflow):

  1. Via runtimeVersion, which is set in expo.modules.updates.EXPO_RUNTIME_VERSION in the AndroidManifest.xml file:

    ...
    <meta-data android:name="expo.modules.updates.EXPO_RUNTIME_VERSION" android:value="1.001"/>
    ...
    

    In this case, I have to increment the value of the Runtime Version every time I make a change that involves installing new packages or any other change which is not purely related to the JavaScript of the app.

  2. Via sdkVersion, which is set in expo.modules.updates.EXPO_SDK_VERSION in the AndroidManifest.xml file:

    ...
    <meta-data android:name="expo.modules.updates.EXPO_SDK_VERSION" android:value="44.0.0"/>
    ...
    

    In this case, I also have to increment the value of the SDK Version every time I make a big change as the one described before.

So, these are the two possible ways in which I understand that I can manage these versions (one or the other). However, I was confused about the fact that the parameters sdkVersion and runtimeVersion are also present in the file app.json.

...
  "name": "MyApp",
  "expo": {
    "name": "MyApp",
    "slug": "myapp",
    "version": "1.0.0",
    "runtimeVersion": "1.001",
    "icon": "./assets/icon.png",
...

or

...
  "name": "MyApp",
  "expo": {
    "name": "MyApp",
    "slug": "myapp",
    "version": "1.0.0",
    "sdkVersion": "44.0.0",
    "icon": "./assets/icon.png",
...

Is this another way of defining these parameters? It would certainly be a lot easier than having to dig out the AndroidMainfest.xml. Also, there are other version-related parameters like version in both app.json and packages.json. Are these related to the same thing, or are they something else entirely?

Finally, what is the general convention as to the formatting of the version numbers in both cases?

1

There are 1 answers

0
Clerni On BEST ANSWER

So, the way I am finally doing it is as follows:

  • In project_root/android/app/src/main/AndroidManifest.xml:

    ...
        <meta-data android:name="expo.modules.updates.EXPO_UPDATE_URL" android:value="https://exp.host/@username/ProjectName"/>
        <meta-data android:name="expo.modules.updates.ENABLED" android:value="true"/>
        <meta-data android:name="expo.modules.updates.EXPO_SDK_VERSION" android:value="44.0.0"/>
        <meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ALWAYS"/>
        <meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="0"/>
    ... 
    
  • In package.json:

    {
        "name": "ProjectName",
        "version": "1.0.0",
        ...
    }
    
  • In app.json:

    {
        "name": "Project Name",
        "displayName": "Project Display Name",
        "expo": {
           "name": "Project Name",
           "slug": "ProjectName",
           "version": "1.0.0",
           ...
        }
    }
    

There is no need to touch the AndroidManifest.xml file at all when incrementing the version numbers. You only need to change the version value in package.json and app.json.