本文介绍了如何在Android中测试应用内更新?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,Google在Google I/O 2019中引入了应用内更新".

Recently, Google introduced 'in-app updates' in Google I/O 2019.

所以我正在尝试使用它.

So I am trying to use it.

val appUpdateManager = AppUpdateManagerFactory.create(this)
val appUpdateInfo = appUpdateManager.appUpdateInfo
appUpdateInfo.addOnCompleteListener {
    val result = it.result
    if (result.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
            && result.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE)) {

        info("should show update")
        appUpdateManager.startUpdateFlowForResult(
                        result,
                        AppUpdateType.FLEXIBLE,
                        this,
                        1)
    } else {
        info("This is already latest version: ${result.updateAvailability()}")
    }
}

但是result.updateAvailability()始终是UpdateAvailability.UPDATE_NOT_AVAILABLE.

为此,我制作了一个带有先前版本代码的签名发行版APK.但这不起作用.

To do this, I made a signed release apk with previous version code.But it doesn't work.

根据开发者主题演讲(16:40〜)上的演示

According to the demo on the Developer Keynote (16:40 ~ )

他正在用仿真器来做.看起来像调试模式.

He is doing it with the emulator.It looks like debug mode.

我该怎么做?

推荐答案

使用内部应用程序共享进行测试

测试应用内更新的正确方法是使用内部应用共享(不要与内部测试跟踪相混淆).

Testing using Internal App Sharing

The right way to test in-app update is to use Internal App Sharing (not to be confused with Internal Testing Track).

  1. 首先在内部应用共享 ="noreferrer">这些说明.与内部测试跟踪不同,内部应用程序共享使应用程序立即可用.因此没有等待时间.
  2. 选择通过Google Play进行应用签名.这将允许Google Play对您提供的应用包中为设备生成的APK进行签名.详细信息此处.
  3. 构建您的应用程序捆绑包.通过命令行,它只是./gradlew bundleRelease./gradlew bundle<variant>.
  4. 转到 https://play.google.com/apps/publish/internalappsharing/并上载在app/build/outputs/bundle/<variant>/下的生成的aab文件.给一个体面的名字,其中包括版本代码.
  5. 这将提供复制链接.使用它将此捆绑包安装到您的设备上.
  6. 在您的应用程序build.gradle中添加版本代码,然后构建另一个捆绑包.注意:版本代码是整数,这是要增加的内容.版本名称不同,对此无关紧要.
  7. 类似地将此新捆绑包上传到Internal App Sharing.用版本代码命名.
  8. 这将提供另一个链接.打开链接,这将打开Goog​​le Play,您应该看到更新"选项. 不要单击更新!
  9. 打开您的应用程序,现在您应该会看到应用程序内更新提示.
  1. First setup your Internal App Sharing with the help of these instructions. Unlike Internal Testing Track, Internal App Sharing makes the app available immediately. So there is no waiting time.
  2. Opt-in to app signing by Google Play. This will allow google play to sign the apk generated for the device from the app bundle you provide. Details here.
  3. Build your app bundle. Through command line, it is simply ./gradlew bundleRelease or ./gradlew bundle<variant>.
  4. Go to https://play.google.com/apps/publish/internalappsharing/ and upload the generated aab file which is under app/build/outputs/bundle/<variant>/. Give a decent name that includes version code.
  5. This will provide a link to copy. Use it to install this bundle to your device.
  6. Bump the version code in your app build.gradle and build another bundle. Note: Version code is integer, that's what is to be incremented. Version name is different and it doesn't matter for this.
  7. Similarly upload this new bundle to Internal App Sharing. Name it with the version code.
  8. This will provide another link. Open the link and this opens google play and you should see "Update" option. Don't click on Update!
  9. Open your app and now you should see in-app update prompt.

如果您没有看到提示,并且(如果您已完全按照以下步骤操作),则很可能是您的代码有问题.添加一些日志记录以查看代码中发生了什么.

If you don't see the prompt and if you had followed these steps exactly, most likely, there is an issue with your code. Add some logging to see what is happening in your code.

在我们的测试中,以下内容无助于测试应用内更新(在其他地方建议):

In our testing, the following did NOT help to test in-app updates (which were suggested elsewhere):

  • 重新上传相同的分发包/apk,而不会增加版本代码
  • 将版本代码降低为低于发布的版本

通过内部应用共享成功进行测试之后,我仍然发现通过发布版本测试应用内更新存在一些麻烦.经过一些试验,我能够通过Alpha轨道成功进行测试.我在这里添加步骤(假设您熟悉Google Play控制台的Alpha封闭音轨,并将自己添加为Alpha测试器列表):

Once testing through internal app sharing is successful, I still found some trouble testing in-app update through published versions. After some trials, I was able to successfully test through Alpha track. I'm adding the steps here (I'm assuming you're familiar with Google Play console's Alpha closed track and adding yourself as alpha tester list):

  1. 通过Google Play安装该应用程序的当前版本.这可以来自生产轨道,也可以来自alpha或beta轨道.此版本应该已经实现了应用程序内更新功能,因为这是预期会显示应用程序内更新提示的版本.
  2. 确保仅针对您的应用禁用自动更新.您可以通过Google Play应用上的应用商店列表中的菜单项来执行此操作.我们禁用自动更新,因为我们真的想通过应用内更新来更新应用,而不是在设备充电时通过Google Play更新应用.
  3. 将新版本(递增版本代码,更改版本名称无关紧要)发布到Alpha跟踪中.
  4. 如今,要花一些时间才能将发布的版本显示在Google Play中.您可能需要等待几个小时.
  5. 一旦它出现在Google Play商店中,您可能会急于尝试打开您的应用.如果出现应用内更新提示,您将会很幸运.很有可能不会.即使您继续等待几个小时并继续重新启动应用程序,也可能不会显示应用程序内更新.遵循其余步骤,我不必等待.
  6. 完全关闭您的应用.
  7. 完全关闭Google Play应用.
  8. 清除Google Play应用缓存.我发现不需要清除存储,只需清除缓存即可.
  9. 打开Goog​​le Play并转到我的应用和游戏(位于导航窗格中).
  10. 现在,Google Play将搜索更新.您的应用更新将会显示.当然,不要在这里更新.
  11. 打开您的应用.应用内更新提示应出现.如果没有,请使用内部应用程序共享测试您的应用程序内更新(上一节中的步骤),并确保实施没有问题.
  1. Install current version of the app through Google Play. This can be from production track or alpha or beta track. This version should already have in-app update feature implemented as this is the version that is expected to show in-app update prompt.
  2. Ensure that Automatic Update is disabled just for your app. You can do this through menu item of your app's store listing on Google Play app. We disable automatic update because, we really want to update the app through in-app update instead of Google Play updating the app when your device is charging.
  3. Publish a new version (with version code incremented, changing version name won't matter) to Alpha track.
  4. Nowadays, it takes a while before the published version shows up in Google Play. You may have to wait for several hours.
  5. Once it shows up in Google Play store, you may eagerly try opening your app. You'll be lucky if in-app update prompt shows up. Most likely it won't. In-app update may not show up even if you kept on waiting for several more hours and kept restarting your app. By following the remaining steps I didn't have to wait.
  6. Close your app completely.
  7. Close Google Play app completely.
  8. Clear Google Play app cache. I found that storage need not to be cleared, just the cache.
  9. Open Google Play and go to My Apps & Games from navigation pane.
  10. Now Google Play will search for the updates. Your app update should show up. Do NOT update here, of course.
  11. Open your app. In-app update prompt should appear. If not, test your in-app update with internal app sharing (steps in previous section) and ensure there is no problem with your implementation.

我想类似的过程也应该适用于Beta(开放轨道)和生产轨道.

I guess similar process should work for Beta (open track) and production tracks as well.

即使可以通过Google Play获得更新,对于最终用户来说,要查看应用程序内更新,我认为可能还需要花费一些时间(几天!). Google Play有其自身令人困惑的方式.祝你好运.

Even after the update is available through Google Play, for the end-users to see in-app update, I think it may take quite some time (days!). Google Play has its own confusing ways. Good luck.

这篇关于如何在Android中测试应用内更新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 18:34