Android 中的应用兼容性
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
对于 Android 而言,“应用兼容性”一词是指您的应用可在特定平台版本(通常是最新版本)上正常运行。每次发布新版本时,我们都会推出一些基本变更来提升隐私保护和安全性,并实施一些变更来改善整个操作系统中的总体用户体验。有时,这些变更可能会影响您的应用,因此请务必查看每个发布版本中包含的行为变更,针对这些变更测试应用并向用户发布兼容性更新。
为什么应用兼容性很重要
无论用户是购买了新设备还是在当前设备上安装了更新,只要他们更新到最新 Android 版本,就会立即受到应用兼容性的影响。他们会迫不及待地想要探索最新 Android 版本的功能,并且希望在新版本上使用他们喜爱的应用。如果这些应用无法正常运行,则会给用户和您带来严重问题。
平台行为变更的类型
在新的平台版本上运行时,您的应用可能会受到两种不同类型的变更的影响:
针对所有应用的变更
这些变更会影响在相应 Android 版本上运行的所有应用,无论应用的 targetSdkVersion
为何。
您应该在每个新 Android 版本的开发者预览版和 Beta 版阶段主动测试应用与这些变更的兼容性。在新的 Android 版本达到最终版本(面向 Android 开源项目 [AOSP] 发布)后,Pixel 和其他设备的更新即会开始,因此,如果您主动针对这些变更进行测试,将有助于确保用户能够在这些设备上无缝过渡到最新 Android 版本。
针对性变更
这些变更只会影响以相应 Android 版本为目标平台的应用。
对于这些变更,您应该在准备以最新稳定版 API(Android 16 [API 级别 36])为目标平台时执行兼容性测试。即使您不打算立即以新的 Android 版本为目标平台,处理这些变更也可能需要进行大量开发工作。您应该尽早了解这些变更。最好是在每个新 Android 版本的开发者预览版和 Beta 版阶段就了解,以便您进行初步测试并提供反馈。
兼容性框架工具
为了帮助您测试兼容性,我们在兼容性框架中针对每个版本纳入了尽可能多的重大更改。将变更纳入到兼容性框架中会使其变为可切换状态,从而使您能够通过开发者选项或 adb 单独强制启用或停用各项变更。使用兼容性框架时,您无需更改应用的 targetSdkVersion
或重新编译应用来执行基本测试。
如需了解详情,请参阅测试和调试应用中的平台行为变更。
针对非 SDK 接口的限制
我们一直在努力让开发者逐步停止使用非 SDK API,因此,我们会在每个 Android 版本中更新受限非 SDK 接口的列表。与往常一样,欢迎您随时提供反馈和请求公共 API 等效项。
详细了解最新 Android 版本:
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-21。
[null,null,["最后更新时间 (UTC):2025-08-21。"],[],[],null,["# App compatibility in Android\n\nFor Android, the term *app compatibility* means that your app runs properly on a\nspecific version of the platform, typically the latest version. With each\nrelease, we make integral changes that improve privacy and security, and we\nimplement changes that evolve the overall user experience across the OS.\nSometimes these changes can affect your apps, so it's important to take a look\nat the behavior changes that are included in each released version, test against\nthem, and publish compatibility updates for your users.\n\nWhy app compatibility is important\n----------------------------------\n\nApp compatibility starts to affect your users immediately when they update to\nthe latest version of Android, whether they've purchased a new device or\ninstalled an update on their current device. They're excited to explore the\nlatest version of Android, and they want to experience it with their favorite\napps. If their apps don't work properly, it can cause major issues both for them\nand for you.\n\nTypes of platform behavior changes\n----------------------------------\n\nYour app can be affected by two different types of changes when running on a new\nplatform version:\n\n### Changes for all apps\n\nThese changes affect all apps that run on that version of Android, regardless of\nan app's `targetSdkVersion`.\n\nYou should test your app's compatibility with these changes proactively during\nthe developer preview and beta releases of each new Android version. Updates to\nPixel and other devices start as soon as a new Android version reaches its final\nrelease to [Android Open Source Project (AOSP)](https://source.android.com/), so when you test proactively\nfor these changes, you help ensure that your users can seamlessly transition to\nthe latest Android version on these devices.\n\n### Targeted changes\n\nThese changes only affect apps that are targeting that version of Android.\n\nFor these changes, you should perform compatibility testing as you prepare to\n[target the latest stable API version](/distribute/best-practices/develop/target-sdk), which is\nAndroid 16 (API level 36). Even if you aren't planning to target a new\nAndroid version immediately, addressing these changes can require a significant\namount of development. You should learn about these changes as early as\npossible---ideally during the developer preview and beta releases of each new\nAndroid version---so you can do preliminary testing and provide feedback.\n\nCompatibility framework tools\n-----------------------------\n\nTo help you test for compatibility, we include as many of the breaking changes\nas possible each release in the compatibility framework. Including a change in\nthe compatibility framework makes it toggleable, letting you force-enable or\ndisable the changes individually from developer options or ADB. When using the\ncompatibility framework, you don't need to change your app's `targetSdkVersion`\nor recompile your app for basic testing.\n\nTo learn more, see [Test and debug platform behavior changes in your app](/guide/app-compatibility/test-debug).\n\nRestrictions on non-SDK interfaces\n----------------------------------\n\nAs part of our ongoing effort to gradually move developers away from non-SDK\nAPIs, we update the [lists of restricted non-SDK interfaces](/guide/app-compatibility/restrictions-non-sdk-interfaces) in each Android\nrelease. As always, your feedback and [requests for public API equivalents](/guide/app-compatibility/restrictions-non-sdk-interfaces#feature-request)\nare welcome.\n\nPlatform releases\n-----------------\n\nLearn more about the latest Android releases:\n\n- [Android 15 (API level 35)](/about/versions/15)\n- [Android 14 (API level 34)](/about/versions/14)\n- [Android 13 (API level 33)](/about/versions/13)\n- [Android 12 (API levels 31, 32)](/about/versions/12)\n- [Android 11 (API level 30)](/about/versions/11)"]]