用android Studio 做了一个应用,想发布在google play 里,就碰到一个版本的问题。
我上传了一个版本,更新了一点点,结果有这样一个错误:Version code 1 has already been used. Try another version code。本文就这问题的解决做个小总结。
google 这个错误,找到下面这个链接:android - Version code 1 has already been used. Try another version code - Stack Overflow
有个答案原文这样说的:
You have two ways to solve this, if you released your bundle already, then you have to update your version code like in balu k's answer,
If you're still developing and pushed app bundle for say, testing, and then you delete it, this bundle is saved as a draft with that version code. Therefore, it says that you can't use the same version because it already sees another one with the same version name.
Here's how you fix it:
- Go to the release section
- go to app bundle explorer, in the top right you should see a dropdown button for you app version, click on it.
- A bottomsheet will show containing all the previous app bundles you uploaded it. Delete the one with clashing bundle version and you're good to go.
这个方法是你的版本还没发行,只想更新一下,我就是这个情况。我就照做了,ok。
后面一种方法是在安卓开发里改版本,这个链接里也有介绍,不过我没办法测试,就是找不到那个文件。
我再查找了一下,找到方法了。
就是更改build.gradle(Module)这个文件,内容如下:
defaultConfig {
applicationId "com.liwensoft.recognizefindtext"
minSdk 24
targetSdk 33
versionCode 2 //from 1=>2
versionName "1.1" //1.0 => 1.1
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
只是其中一段,这样就更改了版本,更改地方看我的那个注释。
我把这签名成包后再上传,效果如下:
再回到第一种方法,只有inactive 的这种未发行包才可以删除。跟着右箭头,到了下面界面:
对于处于active 状态,这个delete 就不会出现。
我是边做边总结,做一个发行还不容易,现在还是测试阶段。