首页 文章

上传失败您需要为APK使用不同的版本代码,因为您已经拥有版本代码为2的版本代码

提问于
浏览
80

根据这个答案How to solve "Your APK's version code needs to be higher than 2." in Google Play's Developer Console?我刚刚将版本代码从2更改为3,但无法上传构建版本 .

在我上传apk之前,这是我的旧清单

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="mypackage name"
    android:installLocation="auto"
    android:versionCode="28"
    android:versionName="1.0028" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="19" />
        .....

这是我必须在Android开发者控制台上传的新版本代码 . 看我的清单

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="mypackage name"
    android:installLocation="auto"
    android:versionCode="2"
    android:versionName="2.0001" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="19" />
        ......

我不知道这个问题是什么 . 有帮助吗?
enter image description here

14 回答

  • 73

    如果您正在使用phonegap / cordova应用程序,只需编辑您的config.xml并在小部件中添加android-versionCode和版本 .

    <widget id =“com.xxx.yyy”version =“1.0.1”xmlns =“http://www.w3.org/ns/widgets”xmlns:cdv =“http://cordova.apache.org /ns/1.0“android-versionCode =”100001“version =”1.0.1“>

  • 3

    如果您使用的是Android Studio,则可以:

    构建 - >编辑风味

    并从那里更改版本代码和名称 .

    enter image description here

  • 4
    android:versionCode="28"
    

    您之前的 versionCode 是28.您应该将其增加1到29 .

    android:versionCode="29"
    

    据推测,您以前的应用程序版本是1到28.通过使用versionCode 3发布,您与已使用此版本代码发布的应用程序的先前版本相冲突 .

  • 2

    对于使用Android Studio的用户,可以通过在 build.gradle 而不是 AndroidManifest.xml 中编辑 versionCodeversionName 来解决问题 .

    例如

    defaultConfig {
        applicationId "com.my.packageId"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 2      <-- change this
        versionName "2.0"  <-- change this
    }
    
  • 0

    如果您使用 ionic framework ,请转到 config.xml 文件并更改 "widget" 标记中的 "version" 属性 . 增加版本号 . 然后重建,签名并上传你的apk到Play商店 . 这解决了我的问题 .

  • 17

    就我而言,这是一个简单的问题 . 我已经在控制台中上传了一个应用程序,所以我在解决一些问题后尝试重新上传它我所做的就是从神器库中删除以前的APK

  • 6

    在Android Studio 1.1.0中,在 build.gradle 中为 Module: app 更改 versionCode ,并且不一定要更改 versionName

    android {
    ...
        defaultConfig {
    ...
            versionCode 3
            versionName "1.0"
        }
    ...
    }
    
  • 0

    正如Martin Konecny的answer所说,你需要将versionCode更改为更高的值 .

    您之前的版本代码是 28 . 它应该改为 29 .

    根据document on the android developer website.版本代码是

    一个整数值,表示相对于其他版本的应用程序代码的版本 .

    所以它应该与之前的versionCode相关(通过相关的意思是更高),如文档所述:

    您应该确保应用程序的每个后续版本都使用更大的值 .

    正如文件中再次提到的那样

    android:versionCode值不一定与用户可见的应用程序发行版本有很强的相似性(参见android:versionName,下面)

    因此,即使这是您的应用程序的发布 2.0001 ,也不一定意味着versionCode是 2 .

    希望这可以帮助 :)

  • 167

    当您尝试上载与Playstore上已有版本值相同的apk时,会出现此错误 .

    只需在build.gradle文件中更改以下内容=> versionCode和versionName

    defaultConfig {
        applicationId "com.my.packageId"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 2      <-- increment this by 1
        versionName "2.0"  <-- this is the version that shows up in playstore, 
                               remember that the versioning scheme goes as follows.
                               first digit = major breaking changes version
                               second digit = minor changes version
                               third digit = minor patches and bug fixes.
                               e.g versionName "2.0.1"
    }
    
  • 0

    如果您正在使用具有Expo的Building Standalone Apps,则由于标准 app.json config仅引用了 version 属性,因此versionCode错误可能会出现问题 .

    我能够在 android 下添加 versionCode 属性,如下所示:

    示例App.json

    {
      "expo": {
        "sdkVersion": "29.0.0",
        "name": "App Name",
        "version": "1.1.0",
        "slug": "app-name",
        "icon": "src/images/app-icon.png",
        "privacy": "public",
        "android": {
          "package": "com.madhues.app",
          "permissions": [],
          "versionCode": 2 // Notice the versionCode added under android.
        }
      }
    }
    

    详细文档:https://docs.expo.io/versions/v32.0.0/workflow/configuration/#versioncode

  • 9

    这似乎是因为您已经将版本3的APK文件上传到Google Play商店 . 再次,您正在上传相同版本的apk . 所以这个问题已经发生了 .

    因此,对于解决方案,您需要更改版本名称和版本代码(以1为增量)并运行应用程序一次,导出后将其上传到Google Play .

  • 2

    如果您的Flutter App的Android APK出现此错误,请在defaultConfig {}下的app / build.gradle文件中

    评论出来

    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
    

    并添加

    versionCode 2
    versionName "2"
    

    或“以前的版本代码”1 .

  • 0

    我一次又一次地得到同样的错误,

    最后我使用 Google Play Console 手动上传了apk文件,如屏幕截图所示 .

    在App Release下,您选择屏幕截图中显示的按钮"CREATE RELEASE"并从 /android/app/bin/build/outputs/apk/release/app-release.apk 上传您的apk文件

    enter image description here

  • 2

    在我的情况下,我的 AndroidManifest 中有类似的东西,

    javaCompileOptions {
            annotationProcessorOptions {
                arguments = [
                        'androidManifestFile': 'app\\build\\intermediates\\merged_manifests\\debug\\processDebugManifest\\merged\\AndroidManifest.xml'
                ]
            }
       }
    

    这里'androidManifestFile'位置错误,改为

    "androidManifestFile": "$projectDir/src/main/AndroidManifest.xml".toString()
    

    一切顺利

相关问题