了解如何使用基本调试技术修复更新问题。
本指南展示了如何验证我们的配置,以便我们可以找到问题的根源,例如应用未显示已发布的更新。在任何给定时间告知应用的当前状态非常重要,因此 EAS 更新是在构建时考虑到这一点的。一旦我们知道哪些更新正在哪些版本上运行,我们就可以进行更改,以便我们的应用处于我们期望的状态。
¥This guide shows how to verify our configuration so that we can find the source of problems like an app not showing a published update. It's important to tell the current state of our app at any given time, so EAS Update was built with this in mind. Once we know which updates are running on which builds, we can make changes so that our apps are in the state we expect.
如果我们不使用 EAS Build,我们的部署页面将为空。请按照 无需 EAS Build 的调试配置 上的指南进行操作。
¥If we are not using EAS Build, our Deployments page will be empty. Follow the guide on debugging configuration without EAS Build instead.
¥Go to the Deployments page
EAS 网站有一个 部署页面,显示我们应用的当前状态。术语“部署”是指一组构建及其相应的更新。如果我们使用 EAS 进行了构建和更新,我们可以在网站上的“部署”选项卡中查看项目的状态。
¥The EAS website has a Deployments page that shows the current state of our app. The term deployment refers to a group of builds and their corresponding updates. If we've made builds and updates with EAS, we can see our project's status on the website in the Deployments tab.
¥Common problems
以下部分介绍常见问题以及如何解决这些问题。下图显示了 EAS 更新的工作原理以及在查找问题根本原因时可用于检查的点。在接下来的部分中,我们将检查和验证这些点以及更多内容。
¥The following section describes common problems and how to fix them. Below is a diagram of how EAS Update works and the spots that are useful to inspect when finding the root cause of an issue. In the following sections, we'll inspect and verify these spots and more.
¥Unexpected channel
如果部署通道是意外的,则意味着我们的构建不是使用正确的通道构建的。要解决此问题,请 配置我们的通道 并重建我们的应用。
¥If the deployment channel is unexpected, it means our build was not built with the correct channel. To fix this, configure our channel and rebuild our app.
¥Unexpected runtime version
如果部署运行时版本是意外的,则意味着我们的构建不是使用正确的运行时版本构建的。要解决此问题,请 配置我们的运行时版本 并重建我们的应用。
¥If the deployment runtime version is unexpected, it means our build was not built with the correct runtime version. To fix this, configure our runtime version and rebuild our app.
¥Unexpected branch
如果部署有意外分支,我们需要 将我们的通道映射到正确的分支。
¥If the deployment has an unexpected branch, we need to map our channel to the correct branch.
¥Missing updates
显示的部署没有任何更新。为了解决这个问题,向分支发布更新.如果更新已发布,请检查 更新页面 以确保它与我们构建的运行时版本匹配。
¥The displayed deployment does not have any updates. To fix this, publish an update to the branch. If an update was already published, check the Updates page to make sure it matches the runtime version of our build.
¥Missing branch
显示的部署具有正确的通道,但未链接到分支。为了解决这个问题,将通道映射到正确的分支.
¥The displayed deployment has the correct channel, but it is not linked to a branch. To fix this, map the channel to the correct branch.
¥Missing deployment
如果未显示我们的部署,则意味着我们的构建未正确配置 EAS 更新。要解决此问题,请执行 配置我们的通道、配置我们的运行时版本 并验证我们的 通用配置。进行这些更改后,我们需要重建我们的应用。
¥If our deployment is not displayed, it means our build is not configured properly for EAS Update. To fix this, configure our channel, configure our runtime version and verify our general configuration. We'll need to rebuild our app after making these changes.
¥Automatic roll back when an update crashes
如果“部署”页面上的所有内容看起来都正确,但你的应用仍显示上一个更新或嵌入构建的代码,则你的新更新的代码可能正在崩溃。当应用下载并应用新更新后,此新更新在根组件渲染之前崩溃时,可能会发生这种情况。
¥If everything looks correct on the Deployments page, but your app still shows the previous update or the code embedded with the build, your new update's code may be crashing. This can happen when this new update crashes before the root component renders after the app downloads and applies the new update.
如果 EAS Update 检测到新更新在启动后不久崩溃,则会自动回滚到上一个更新。请参阅 EAS Update 如何检测崩溃并回滚到以前的工作版本 了解更多信息。
¥EAS Update is designed to automatically roll back to the previous update if it detects that a new update crashed shortly after launch. See how EAS Update detects crashes and rolls back to a previous working version for more information.
要诊断导致更新崩溃的错误:
¥To diagnose the error causing the update crash:
请参阅 运行时问题故障排除指南 以应用策略来识别错误。
¥See the Troubleshooting guide on runtime issues to apply a strategy to identify the error.
识别错误后,发布修复崩溃的新更新以解决问题。
¥After identifying the error, publish a new update that fixes the crash to resolve the issue.
新更新不起作用但嵌入代码起作用的常见原因是缺少环境变量。请参阅 环境变量如何与 EAS Update 配合使用 了解更多信息。
¥A common reason a new update does not work but embedded code does is due to a missing environment variable. See how environment variables work with EAS Update for more information.
¥Solutions
¥Configure channel
要验证构建是否具有特定通道,请确保 eas.json 中的构建配置文件具有通道属性:
¥To verify that a build has a specific channel, make sure our build profile in eas.json has a channel property:
{
"build": {
"preview": {
"distribution": "internal",
"channel": "preview"
},
"production": {
"channel": "production"
}
}
}
然后,我们可以运行 eas build --profile preview
这样的命令来创建具有名为 "preview" 的通道的构建。
¥Then, we can run a command like eas build --profile preview
to create a build with a channel named "preview".
¥Configure runtime version
为了验证我们的运行时版本,我们确保我们的应用配置(app.json/app.config.js)具有 runtimeVersion
属性:
¥To verify our runtime version, we make sure our app config (app.json/app.config.js) has a runtimeVersion
property:
{
"expo": {
"runtimeVersion": {
"policy": "sdkVersion"
}
}
}
默认情况下,它是 { "policy": "sdkVersion" }
,但我们可以将运行时间更改为 使用不同的策略或特定版本。然后,我们可以运行 eas build --profile preview
这样的命令来创建具有我们期望的运行时版本的构建。
¥By default, it is { "policy": "sdkVersion" }
, but we can change our runtime to use a different policy or a specific version. Then, we can run a command like eas build --profile preview
to create a build with the runtime version we expect.
¥Map channel to branch
如果通道未映射到我们期望的分支,我们可以使用以下命令更改链接:
¥If the channel is not mapped to the branch we expect, we can change the link with:
# eas channel:edit [channel-name] --branch [branch-name]
# Example
-
eas channel:edit production --branch release-1.0
如果我们的分支没有列出,我们可以使用 eas branch:create
创建一个新分支。
¥If our branch is not listed, we can create a new branch with eas branch:create
.
¥Publish update
要创建并发布更新,我们可以运行以下命令:
¥To create and publish an update, we can run the following command:
-
eas update
发布后,输出将显示分支和运行时版本。此信息可以帮助我们验证是否正在使用预期的配置创建更新。
¥After publishing, the output will display the branch and the runtime version. This information can help us verify that we're creating an update with the configuration we expect.
¥Video walkthrough