How can I test In-app updates in Android?(如何在 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 ~ )一个>
他是用模拟器做的.它看起来像调试模式.
He is doing it with the emulator. It looks like debug mode.
我怎样才能做同样的事情?
How can I do this same thing?
推荐答案
使用内部应用共享进行测试
测试应用内更新的正确方法是使用内部应用共享(不要与内部测试轨道混淆).
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).
- 首先在 内部应用共享="noreferrer">这些说明.与内部测试跟踪不同,内部应用程序共享使应用程序立即可用.所以没有等待时间.
- 选择加入 Google Play 应用签名.这将允许 google play 签署从您提供的应用程序包为设备生成的 apk.详情此处.
- 构建您的应用程序包.通过命令行,就是
./gradlew bundleRelease
或者./gradlew bundle
. - 转到 https://play.google.com/apps/publish/internalappsharing/ 并上传生成的
aab
文件,该文件位于app/build/outputs/bundle/<variant>/
下.取一个包含版本代码的体面名称. - 这将提供一个复制链接.使用它来将此捆绑包安装到您的设备上.
- 在您的应用中添加版本代码
build.gradle
并构建另一个包.注意:版本代码是整数,这是要递增的.版本名称不同,这无关紧要. - 同样将这个新捆绑包上传到内部应用共享.用版本号命名.
- 这将提供另一个链接.打开链接,这将打开 google play,您应该会看到更新"选项.不要点击更新!
- 打开您的应用,现在您应该会看到应用内更新提示.
- 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.
- 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.
- Build your app bundle. Through command line, it is simply
./gradlew bundleRelease
or./gradlew bundle<variant>
. - Go to https://play.google.com/apps/publish/internalappsharing/ and upload the generated
aab
file which is underapp/build/outputs/bundle/<variant>/
. Give a decent name that includes version code. - This will provide a link to copy. Use it to install this bundle to your device.
- 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. - Similarly upload this new bundle to Internal App Sharing. Name it with the version code.
- This will provide another link. Open the link and this opens google play and you should see "Update" option. Don't click on Update!
- 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):
- 通过 Google Play 安装当前版本的应用.这可以来自生产轨道或 alpha 或 beta 轨道.此版本应该已经实现了应用内更新功能,因为这是预计会显示应用内更新提示的版本.
- 确保仅为您的应用禁用自动更新.您可以通过 Google Play 应用上您的应用商店列表的菜单项来执行此操作.我们禁用自动更新是因为,我们确实希望通过应用内更新来更新应用,而不是在您的设备充电时通过 Google Play 更新应用.
- 将新版本(版本代码递增,更改版本名称无关紧要)发布到 Alpha 轨道.
- 现在,发布的版本需要一段时间才能显示在 Google Play 中.您可能需要等待几个小时.
- 一旦它出现在 Google Play 商店中,您可能会迫不及待地尝试打开您的应用.如果出现应用内更新提示,您会很幸运.很可能不会.即使您继续等待几个小时并不断重新启动您的应用程序,应用程序内更新也可能不会显示.按照剩下的步骤,我不必等待.
- 完全关闭您的应用.
- 完全关闭 Google Play 应用.
- 清除 Google Play 应用缓存.我发现不需要清除存储空间,只需清除缓存即可.
- 打开 Google Play 并转到 我的应用和导航窗格中的游戏.
- 现在 Google Play 将搜索更新.您的应用更新应该会显示出来.当然,不要在这里更新.
- 打开您的应用.应出现应用内更新提示.如果没有,请使用内部应用共享测试您的应用内更新(上一节中的步骤),并确保您的实施没有问题.
- 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.
- 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.
- Publish a new version (with version code incremented, changing version name won't matter) to Alpha track.
- Nowadays, it takes a while before the published version shows up in Google Play. You may have to wait for several hours.
- 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.
- Close your app completely.
- Close Google Play app completely.
- Clear Google Play app cache. I found that storage need not to be cleared, just the cache.
- Open Google Play and go to My Apps & Games from navigation pane.
- Now Google Play will search for the updates. Your app update should show up. Do NOT update here, of course.
- 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 中测试应用内更新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 Android 中测试应用内更新?
基础教程推荐
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01