expo / eas-cli

Fastest way to build, submit, and update iOS and Android apps
https://docs.expo.dev/eas/
MIT License
845 stars 85 forks source link

eas update doesn't work with a custom expo.updates.url value #2559

Open juanvelozo opened 2 months ago

juanvelozo commented 2 months ago

Build/Submit details page URL

No response

Summary

I'm looking to add OTA Updates to my React Native application, but I want to implement my own server (I'm not paying the official expo way to deliver OTA updates), but I encountered the issue that the eas update command doesn't allow me to upload the update to my server and requires me to modify the value of expo.updates.url to a expo server link. My question here is, can I use a custom update server url? I'm using a dynamic configuration in my app.config.js, is that a problem? When I put the requested expo url into expo.updates.url the update uploads successfully, but I don't want to send my updates to the official expo server.

Also, I'm using a plugin to modify the androidManifest to include my server url as the mentioned in this documentation

Someone has experience on delivering OTA Updates through a custom server?

Managed or bare?

Bare

Environment

expo-env-info 1.2.0 environment info: System: OS: Windows 11 10.0.22631 Binaries: Node: 18.20.3 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.19 - C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: 10.7.0 - C:\Program Files\nodejs\npm.CMD SDKs: Android SDK: API Levels: 29, 31, 33, 34 Build Tools: 30.0.3, 31.0.0, 33.0.0, 33.0.1, 33.0.2, 34.0.0, 35.0.0 System Images: android-30 | ARM 64 v8a, android-30 | Intel x86_64 Atom, android-30 | Google APIs Intel x86 Atom, android-30 | Google Play Intel x86 Atom IDEs: Android Studio: AI-231.9392.1.2311.11330709 npmPackages: babel-preset-expo: ^10.0.0 => 10.0.2 expo: ~50.0.17 => 50.0.19 react: 18.2.0 => 18.2.0 react-dom: 18.2.0 => 18.2.0 react-native: 0.73.6 => 0.73.6 react-native-web: ~0.19.6 => 0.19.12 Expo Workflow: bare

Error output

It looks like you are using a dynamic configuration! Learn more: https://docs.expo.dev/workflow/configuration/#dynamic-configuration-with-appconfigjs) Add the following EAS Update key-values to the project app.config.js: Learn more: https://expo.fyi/eas-update-config

{ "updates": { "url": "https://u.expo.dev/eb476e9e-a825-42bb-9ee4-5a245edaf30e" } }

Cannot automatically write to dynamic config at: app.config.js Error: update command failed.

Reproducible demo or steps to reproduce from a blank project

  1. You should have an .apk installed on your android device that aims to your OTA server. This can be achieve by configuring your androidManifest.xml to listen to your updates server. Create a file called AndroidManifestConfig.js and add the following code:
    
    /* eslint-disable import/no-commonjs */
    const { withAndroidManifest } = require("@expo/config-plugins");

module.exports = (config) => { return withAndroidManifest(config, (config) => { const manifest = config.modResults;

const application = manifest.manifest.application[0];
if (!application) {
  throw new Error("No se encontró el nodo <application> en AndroidManifest.xml");
}

if (!application["meta-data"]) {
  application["meta-data"] = [];
}

const updateMetaData = (name, value) => {
  const metaDataItem = application["meta-data"].find((item) => item.$["android:name"] === name);
  if (metaDataItem) {
    metaDataItem.$["android:value"] = value;
  } else {
    application["meta-data"].push({
      $: {
        "android:name": name,
        "android:value": value,
      },
    });
  }
};

updateMetaData("expo.modules.updates.ENABLED", "true");
updateMetaData("expo.modules.updates.EXPO_RUNTIME_VERSION", "@string/expo_runtime_version");
updateMetaData("expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH", "ALWAYS");
updateMetaData("expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS", "30000");
updateMetaData(
  "expo.modules.updates.EXPO_UPDATE_URL",
  "the_url_to_your_server"
);

return config;

}); };

2. Add the following values to your `app.config.js`:

expo: { updates: { url: "localhost:3000", fallbackToCacheTimeout: 0, }, runtimeVersion: "1.0.0", extra: { eas: { projectId: "eb476e9e-a825-42bb-9ee4-5a245edaf30e", }, }, owner: "juanvelozo", slug: "yourSlug", android: { package: "com.yourapp", }, },


3. run `eas update`
giovannicm1999 commented 2 months ago

Any updates about this? Same problem here :/

dhcmega commented 2 months ago

Hi, I also have this problem. Thanks.

giovannicm1999 commented 2 months ago

I've checked the EAS CLI rules and found a rule (below) that replaces the value of the custom server in app.json if the value of 'expo.updates.url' is different from the default EAS update URL (e.g., https://u.expo.dev/eb476e9e-a825-42bb-9ee4-5a245edaf30e).

image

I'm not sure why this happens, but I think using 'eas update' is not the correct approach for custom servers.

Following the setup guide in the custom server repository (https://github.com/expo/custom-expo-updates-server?tab=readme-ov-file#the-setup), I believe the right way to use custom servers is to generate the client's build and save it in the update directory yourself, similar to how the publish.sh script works in the custom server repository (https://github.com/expo/custom-expo-updates-server/blob/main/expo-updates-server/scripts/publish.sh).

dhcmega commented 2 months ago

Oh wow! Of course, that's why the docs have the npx expo export command. Thanks!