android - 有没有办法在 AVD 模拟器上模拟 Android 操作系统升级场景?

标签 android android-emulator apk

我一直在尝试模拟一个场景,我想在操作系统更新后检查我的 Android 应用程序的行为。但是目前我无法访问物理设备,我可以运行实际的操作系统更新场景,所以我不得不求助于在 android 模拟器 (AVD) 上进行尝试。
有没有一种方法可以让我在 AVD 上更新操作系统,就像它是一部真正的手机一样,并且能够看到我的应用程序的行为方式?

我基本上想测试的是:
假设我在设备上安装了 API 级别 21 的 android。我使用 maxSdkVersion 安装应用程序21 就可以了。现在我的设备升级到 API 级别 22。我的应用会怎样?

  • 操作系统会默默地卸载我的应用程序并保持这种状态吗?
  • 操作系统是否会与 Play 商店核对以查看具有受支持的 SDK 级别的我的应用程序的构建是否可用,然后下载并安装它?
  • 操作系统是否会至少给我一个视觉警告或提示这个特定应用程序不再在设备上兼容,并告诉我下一步我能做什么?

  • Android Developer Docs建议使用 maxSdkVersion不是一个好主意,因为 在某些情况下会发生卸载。

    An application declaring maxSdkVersion="5" in its manifest is published on Google Play. A user whose device is running Android 1.6 (API Level 4) downloads and installs the app. After a few weeks, the user receives an over-the-air system update to Android 2.0 (API Level 5). After the update is installed, the system checks the application's maxSdkVersion and successfully re-validates it. The application functions normally. However, some time later, the device receives another system update, this time to Android 2.0.1 (API Level 6). After the update, the system can no longer re-validate the application because the system's own API Level (6) is now higher than the maximum supported by the application (5). The system prevents the application from being visible to the user, in effect removing it from the device.

    Warning: Declaring this attribute is not recommended. First, there is no need to set the attribute as means of blocking deployment of your application onto new versions of the Android platform as they are released. By design, new versions of the platform are fully backward-compatible. Your application should work properly on new versions, provided it uses only standard APIs and follows development best practices. Second, note that in some cases, declaring the attribute can result in your application being removed from users' devices after a system update to a higher API Level. Most devices on which your application is likely to be installed will receive periodic system updates over the air, so you should consider their effect on your application before setting this attribute.



    我还想弄清楚接下来会发生什么。 “在某些情况下”本质上是什么意思?

    最佳答案

    我创建了 2 个演示应用程序来使用模拟器检查您的问题。我已经更新了模拟器的 API 级别并重新启动它,因为每个设备都会在系统更新后重新启动。请看 this视频发生了什么:)

    Will the OS silently get my app uninstalled and keep it that way?


    是的,应用程序被卸载

    Will the OS at least give me a visual warning or prompt that this particular app is not compatible on the device anymore and tell me what I could do next?


    应用程序在没有任何消息或警告的情况下被卸载

    Will the OS check with play store to see if a build of my app with a supported SDK level is available and download and install that instead?


    我认为这可以检查应用程序是否在 Play 商店中可用。所以我无法对此进行测试。如果有人知道这个问题的答案,请评论

    关于android - 有没有办法在 AVD 模拟器上模拟 Android 操作系统升级场景?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46847627/

    相关文章:

    android - 在 API 级别 17 从 Android 浏览器启动 Activity

    android - 如何故意减慢模拟器的速度?

    android - Android上的“未安装应用程序”错误

    linux - 如何使用 apk 安装 readline

    用于多项操作的 Android 接收器?

    android - 滚动时 ListPreference 崩溃

    android - android galaxy的真实设备数据库文件为空点异常

    android - 生成签名的 apk 时魔数(Magic Number)不匹配

    android - 由于证书不同,无法将更新的 APK 上传到 Google Play

    android - 在android中创建推送通知