6

I want to update my app on google play store, it can't accept the updated file with the same version.

Do I've changed the version from build.gradle file :

android {
compileSdkVersion 21
buildToolsVersion "21.1.2"

defaultConfig {
    applicationId "net.koorasudan.app"
    minSdkVersion 14
    targetSdkVersion 21
    versionCode 5.1
    versionName "5.1"
}
buildTypes {
    release {
           minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

But when I sync the gradle it shows me this error :

Error:(23, 0) Gradle DSL method not found: 'versionCode()' Possible causes:

  • The project 'SmartView 3' may be using a version of Gradle that does not contain the method. Open Gradle wrapper file
  • The build file may be missing a Gradle plugin. Apply Gradle plugin
  • How to solve this problem?

    Gabriele Mariotti
    • 320,139
    • 94
    • 887
    • 841
    KingoC
    • 167
    • 3
    • 15
    • possible duplicate of [Gradle DSL method not found: 'runProguard'](http://stackoverflow.com/questions/27078075/gradle-dsl-method-not-found-runproguard) – Dijkgraaf Jul 02 '15 at 20:56

    6 Answers6

    19

    The versionCode is an integer.

    You can't use versionCode 5.1 in your build.gradle

    Also you have to add this line at the beginning of your script.

    apply plugin: 'com.android.application'
    
    Gabriele Mariotti
    • 320,139
    • 94
    • 887
    • 841
    3

    Did you add the android plugin on top of the gradle file?

    apply plugin: 'android'
    

    Version code needs to be an integer by the way! switch from 5.1 to 5 and it will work!

    Peter P
    • 491
    • 4
    • 14
    3

    FWIW: I have encountered this problem when testing for large version codes (>= 10 digits). Gradle bug?

    kip2
    • 6,473
    • 4
    • 55
    • 72
    • No, it's not a bug. Version code needs to be an integer, i switch it from 5.1 to 5 and it worked! – KingoC Aug 07 '16 at 08:44
    • Version codes greater than 2100000000 will give this exact same error message. The [docs mention that this is the highest version number allowed](https://stackoverflow.com/questions/55749856/gradle-dsl-method-not-found-versioncode) – James Allen Jul 14 '19 at 16:12
    2

    You should put your version code as Integer. after any publication of your app you have to increase version code so that the android OS finds out that this version is newer one.

    but in Version name you can put what ever you want in string format.

    hope usefull

    Mahdi
    • 6,139
    • 9
    • 57
    • 109
    1

    Version code should be in integer format.

    Please use the code below:

    <i>
    android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"
    defaultConfig {
        applicationId "net.koorasudan.app"
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 5
        versionName "5.1"
    }
    buildTypes {
        release {
               minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
        }
    }
    </i>
    
    Mahmoud Abdelsattar
    • 1,299
    • 1
    • 15
    • 31
    0

    just use version code 2, do not use version code 2.0 or any float value

    versionCode 2

        versionName "2.0"
    

    like this and rebuild the app, it will solve your problem