Android 如何让你的安卓应用自动更新

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11356012/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 07:08:52  来源:igfitidea点击:

How to make your Android app auto update

androidauto-update

提问by dbDev

I published my first app in Google Play today, woot! Once I saw my app listed in Google Play, I realized I needed to make a change and post an update.

我今天在 Google Play 上发布了我的第一个应用,哇!当我在 Google Play 中看到我的应用程序时,我意识到我需要进行更改并发布更新。

I made my code changes and incremented versionCode and versionName in the manifest file. I then built my apk, signed with the same key as the original apk submitted to Google Play.

我更改了代码并增加了清单文件中的 versionCode 和 versionName。然后我构建了我的 apk,使用与提交给 Google Play 的原始 apk 相同的密钥签名。

I uploaded a new apk, deactivated the original apk, then activated the new one and clicked Save.

我上传了一个新的 apk,停用了原来的 apk,然后激活了新的 apk 并单击了保存。

I waited a couple of hours, looked in Google Play and could see that yes, the new value I put in versionName had updated.

我等了几个小时,查看了 Google Play,可以看到是的,我放入 versionName 的新值已更新。

On my Android Phone, I had originally installed the first version, but when I go to Google Play on that phone, I see the new version of my app, but the only options are "Open" and "Uninstall".

在我的 Android 手机上,我最初安装了第一个版本,但是当我在该手机上访问 Google Play 时,我看到了我的应用程序的新版本,但唯一的选项是“打开”和“卸载”。

What do I need to do to my app in the Dev Console, or wherever, so the Update option appears when me or any other user goes to my app in Google Play?

我需要在开发控制台或其他任何地方对我的应用程序执行什么操作,以便在我或任何其他用户在 Google Play 中访问我的应用程序时显示更新选项?

Doing some research in Android Developer, I read this:

在 Android Developer 中做一些研究,我读到了这个:

android:versionCode An internal version number. This number is used only to determine whether one version is more recent than another, with higher numbers indicating more recent versions. This is not the version number shown to users; that number is set by the versionName attribute. The value must be set as an integer, such as "100". You can define it however you want, as long as each successive version has a higher number. For example, it could be a build number. Or you could translate a version number in "x.y" format to an integer by encoding the "x" and "y" separately in the lower and upper 16 bits. Or you could simply increase the number by one each time a new version is released. http://developer.android.com/guide/topics/manifest/manifest-element.html

android:versionCode 内部版本号。此数字仅用于确定一个版本是否比另一个版本更新,数字越大表示版本越新。这不是向用户显示的版本号;该数字由 versionName 属性设置。该值必须设置为整数,例如“100”。您可以根据需要定义它,只要每个后续版本都有更高的编号。例如,它可以是内部版本号。或者,您可以通过将“x”和“y”分别编码为低 16 位和高 16 位,将“xy”格式的版本号转换为整数。或者,您可以在每次发布新版本时简单地将数字增加 1。 http://developer.android.com/guide/topics/manifest/manifest-element.html

Then I found this:

然后我发现了这个:

Google Play can manage updates to preloaded applications, provided the following conditions are met: Package Name with the same Version Code of pre-loaded app must to be uploaded to the Developer Console http://support.google.com/googleplay/android-developer/bin/answer.py?hl=en&answer=113476&topic=2365760&ctx=topic

如果满足以下条件,Google Play 可以管理预加载应用程序的更新: 必须将与预加载应用程序版本代码相同的包名称上传到开发者控制台 http://support.google.com/googleplay/android- developer/bin/answer.py?hl=zh-CN&answer=113476&topic=2365760&ctx=topic

So I'm confused, do I increment the Version Code or not. I'm pretty sure I should increment it, but then again the Update option is not showing up.

所以我很困惑,我是否增加了版本代码。我很确定我应该增加它,但是再次没有显示更新选项。

采纳答案by frogmanx

Congratulations on your first app! It's a very exciting moment!

恭喜您获得第一个应用程序!这是一个非常激动人心的时刻!

Yes, you increment your Version Code when you make an update to your app.

是的,当您更新您的应用程序时,您会增加您的版本代码。

When you were testing your updated version, did you install the apk file onto your device? You might have updated it unknowingly. Google play will therefore detect that you have matching version codes with the app on your device and the app you uploaded and will not offer to update it.

当您测试更新版本时,您是否将 apk 文件安装到您的设备上?你可能在不知不觉中更新了它。因此,Google Play 会检测到您的设备上的应用程序和您上传的应用程序具有匹配的版本代码,并且不会提供更新。

回答by Raghav Sood

You must alwaysincrement the version code when updating an app on Google Play. Your update will not be accepted unless you do.

在 Google Play 上更新应用程序时,您必须始终增加版本代码。除非您接受,否则您的更新将不被接受。

As for your update not showing up, Google Play takes time to refresh it's servers. My updates have sometimes taken more than 24 hours to be pushed to the device, while new installers get the latest version withing 2 hours usually.

至于您的更新没有显示出来,Google Play 需要时间来刷新它的服务器。我的更新有时需要超过 24 小时才能推送到设备,而新安装者通常需要 2 小时才能获得最新版本。