解决Flutter上架Google Play提示Version code 1 has already been used. Try another version code.

简介: 解决Flutter上架Google Play提示Version code 1 has already been used. Try another version code.

出现场景

使用flutter build appbundle打包aab时

因为上个版本是第一个默认版本1.0.0。所以这次打包我们在版本名后面加了1。

name: flutter_demo
description: A new Flutter application for Flutter demo

# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1

上传到Google Play,提示以下错误信息。

Version code 1 has already been used. Try another version code.

原因分析

首先我们得搞清楚Flutter中的版本是如何管理的。

Flutter打包的版本名和版本号默认是从pubspec.yaml中的version读取的。我们只需要更新它的值就可以了。

格式为

version:A.B.C+X

对于Android的版本来说,版本号的管理在app/build.gradle中配置。

android{
    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.exmaple.demo"
        minSdkVersion 21
        targetSdkVersion 31
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }
}

A.B.C代表了verisonName,比如默认初始值为1.0.0.

X代表versionCode,默认值从1开始,依次累加。

默认App的versionName为1.0.0,versionCode为1。

解决方案

因为对于默认的versionName来说,后面不加上versionCode,versionCode就会默认为1.所以1.0.01.0.0+1是没有任何区别的。

我们只需要在versionCode后面加上更大的数字即可。比如+2.

name: flutter_demo
description: A new Flutter application for Flutter demo

# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# 1更改为2
version: 1.0.0+2


重新打包后上传,就能成功上传到Google Play了。


目录
打赏
0
3
3
0
54
分享
相关文章
App上架Apple App Store和Google Play流程
App上架Apple App Store和Google Play流程
206 2
解决 Android App 上架 Google play后 ,签名变更,第三方sdk无法登录
解决 Android App 上架 Google play后 ,签名变更,第三方sdk无法登录
382 0
|
8月前
Flutter-解决Try catch出现异常:type ‘_TypeError‘ is not a subtype of type ‘Exception‘ in type cast
Flutter-解决Try catch出现异常:type ‘_TypeError‘ is not a subtype of type ‘Exception‘ in type cast
185 1
|
3月前
flutter开发中Use ‘const’ with the constructor to improve performance. Try adding the ‘const’ keyword to the constructor invocation.报错如何解决-优雅草卓伊凡
flutter开发中Use ‘const’ with the constructor to improve performance. Try adding the ‘const’ keyword to the constructor invocation.报错如何解决-优雅草卓伊凡
31 1
鸿蒙Flutter实战:13-鸿蒙应用打包上架流程
鸿蒙应用打包上架流程包括创建应用、打包签名和上传应用。首先,在AppGallery Connect中创建项目、APP ID和元服务。接着,使用Deveco进行手动签名,生成.p12和.csr文件,并在AppGallery Connect中上传CSR文件获取证书。最后,配置签名并打包生成.app文件,上传至应用市场。常见问题包括检查签名配置文件是否正确。参考资料:[应用/服务签名](https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/ide-signing-V5)。
164 3
鸿蒙Flutter实战:13-鸿蒙应用打包上架流程
上架Google Play报错:For new apps, Android App Bundles must be signed with an RSA key.
上架Google Play报错:For new apps, Android App Bundles must be signed with an RSA key.
195 1
Android 14适配Google play截止时间临近,适配注意点和经验
本文介绍了Android 14带来的关键更新,包括性能优化、定制化体验、多语言支持、多媒体与图形增强等功能。此外,还强调了适配时的重要事项,如targetSdkVersion升级、前台服务类型声明、蓝牙权限变更等,以及安全性与用户体验方面的改进。开发者需按官方指南更新应用,以充分利用新特性并确保兼容性和安全性。
443 0
Flutter IOS 打包上架踩坑
Flutter IOS 打包上架踩坑
211 0
安卓隐私权政策和Google Play规范更新
【4月更文挑战第14天】谷歌针对安卓平台的隐私权政策和Google Play规范进行重要更新,强化用户隐私保护和安全标准。新政策强调最小化数据收集,要求开发者明确告知用户敏感数据用途,并限制不必要的后台数据处理。Google Play规范更新要求应用详述数据收集方式,增加安全审查机制,确保无恶意代码。开发者面临调整,但有机会提升应用安全标准,赢得用户信任。用户数据安全得到提升,移动生态系统将更健康、可持续。
223 1

热门文章

最新文章

  • 1
    【Flutter 开发必备】AzListView 组件全解析,打造丝滑索引列表!
    46
  • 2
    flutter3-wetrip跨平台自研仿携程app预约酒店系统模板
    52
  • 3
    通过外部链接启动 Flutter App(详细介绍及示例)
    45
  • 4
    【01】噩梦终结flutter配安卓android鸿蒙harmonyOS 以及next调试环境配鸿蒙和ios真机调试环境-flutter项目安卓环境配置-gradle-agp-ndkVersion模拟器运行真机测试环境-本地环境搭建-如何快速搭建android本地运行环境-优雅草卓伊凡-很多人在这步就被难倒了
    227
  • 5
    零基础构建即时通讯开源项目OpenIM移动端-Flutter篇
    121
  • 6
    flutter3-dart3-dymall原创仿抖音(直播+短视频+聊天)商城app系统模板
    83
  • 7
    【11】flutter进行了聊天页面的开发-增加了即时通讯聊天的整体页面和组件-切换-朋友-陌生人-vip开通详细页面-即时通讯sdk准备-直播sdk准备-即时通讯有无UI集成的区别介绍-开发完整的社交APP-前端客户端开发+数据联调|以优雅草商业项目为例做开发-flutter开发-全流程-商业应用级实战开发-优雅草Alex
    193
  • 8
    【09】flutter首页进行了完善-采用android studio 进行真机调试开发-增加了直播间列表和短视频人物列表-增加了用户中心-卓伊凡换人优雅草Alex-开发完整的社交APP-前端客户端开发+数据联调|以优雅草商业项目为例做开发-flutter开发-全流程-商业应用级实战开发-优雅草Alex
    65
  • 9
    当flutter react native 等混开框架-并且用vscode-idea等编译器无法打包apk,打包安卓不成功怎么办-直接用android studio如何打包安卓apk -重要-优雅草卓伊凡
    97
  • 10
    【08】flutter完成屏幕适配-重建Android,增加GetX路由,屏幕适配,基础导航栏-多版本SDK以及gradle造成的关于fvm的使用(flutter version manage)-卓伊凡换人优雅草Alex-开发完整的社交APP-前端客户端开发+数据联调|以优雅草商业项目为例做开发-flutter开发-全流程-商业应用级实战开发-优雅草Alex
    202
  • AI助理

    你好,我是AI助理

    可以解答问题、推荐解决方案等