针对 Android(Go 版本)进行优化
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Android(Go 版本)拥有快速增长的用户群,因此需要优化现有应用以便在这些低 RAM 设备上提供良好的体验。围绕此类开发,一些最常见的挑战需要限制某些应用特性或功能,缩短启动时间,以及处理应用中的内存压力。此时,针对 Android(Go 版本)优化您的应用将大有裨益。
解决方法
在开始应用优化方法之前,请按以下步骤操作。本指南有助于建立基准,以确定潜在的改进领域以及如何解决您的发现结果。
阶段 |
说明 |
定义 |
在开始优化工作之前,请务必围绕您为应用改进的目标确定关键绩效指标 (KPI)。一些常见的改进领域包括应用启动延迟、应用崩溃率或应用无响应 (ANR)。
定义这些 KPI 后,您应从最低用户体验和基准化分析的角度确立目标阈值,平衡用户体验和技术复杂性。
|
细分数据 |
建议将这些改进方面划分为各种单独的信号指标。例如,应用崩溃率可以细分为各种崩溃原因,例如未处理的错误、内存用量高或 ANR。 |
基准 |
接下来,您可以对已确定的改进领域进行基准化分析,以确定当前的表现。如果您的目标未能实现,请尝试查看各个细分项来找出瓶颈问题。 |
重复同一过程 |
优化某些瓶颈后,重复基准测试过程以查看潜在的改进。如果预定义的 KPI 目标未能实现,可以重复执行此流程进行第 2 次迭代。 |
添加常规回归测试 |
定期回归测试可以按您希望应用运行的任何频率运行,以确定是否违反 KPI。在任何回归问题或 bug 侵入您的代码库之前,提前发现和阻止它们效率更高。请勿发布任何未达到您的 KPI 目标的更改,除非您决定更新 KPI 目标。 |
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Optimize for Android (Go edition)\n\nAndroid (Go edition) has a rapidly growing user base, and with that comes the\nneed to optimize existing applications to perform well on these low-RAM devices.\nSome of the most common challenges around this type of development requires\nlimiting some app features or capabilities, improving startup time, and handling\nmemory pressure within your app. That's where optimizing your app for Android\n(Go edition) can help.\n\nApproach\n--------\n\nFollow the steps below before beginning your app optimization approach. This\nguidance helps establish a baseline for identifying potential areas for\nimprovement and how to resolve your findings.\n\n| Phases | Description |\n|------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Define | Before starting any optimization effort, it's important to define Key Performance Indicators (KPIs) around areas of improvement that you're targeting for your app. Some common improvement areas include app startup latency, app crash rate, or application not responding (ANRs). \u003cbr /\u003e Once these KPIs have been defined, you should establish target thresholds from a minimum user experience and benchmarking perspective, balancing user experience and technical complexity. |\n| Breakdown | It's recommended to break these improvement areas into individual signal metrics. For example, app crash rates can be categorized granularly into reasons for the crash --- such as unhandled errors, high memory usage, or ANRs. |\n| Benchmark | Next, you can benchmark the targeted improvement area to identify current performance. If your targets aren't met, try to identify the bottlenecks by looking at individual breakdowns. |\n| Repeat the process | After optimizing certain bottlenecks, repeat the benchmarking process to view potential improvements. If your pre-defined KPI targets aren't met, then you can repeat the process for a second iteration. |\n| Add regular regression tests | Regular regression tests can run at any frequency you desire for your app to identify regressions against your KPIs. It's more efficient to identify and cut off any regressions or bugs before they make their way into your codebase. Don't publish any changes that fail your KPI goals unless you make the decision to update your KPI targets. |"]]