Gradle DSL method not found when updating application version
Asked Answered
R

6

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?

    Rutabaga answered 2/7, 2015 at 20:34 Comment(1)
    possible duplicate of Gradle DSL method not found: 'runProguard'Lithopone
    G
    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'
    
    Galactometer answered 2/7, 2015 at 21:6 Comment(3)
    thank you too, i've add the line on the beginning of the script.Rutabaga
    If this resolves your issue, please mark the answer as correct. It can help other users. thanks.Galactometer
    Changing the versionCode to an Integer works for meBrickle
    F
    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!

    Flimflam answered 2/7, 2015 at 21:3 Comment(0)
    D
    3

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

    Dafna answered 6/8, 2016 at 0:28 Comment(2)
    No, it's not a bug. Version code needs to be an integer, i switch it from 5.1 to 5 and it worked!Rutabaga
    Version codes greater than 2100000000 will give this exact same error message. The docs mention that this is the highest version number allowedOtes
    G
    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

    Gilchrist answered 29/4, 2016 at 13:29 Comment(0)
    C
    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>
    
    Cassilda answered 26/3, 2021 at 12:38 Comment(0)
    O
    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

    Outsmart answered 17/2, 2020 at 8:24 Comment(0)

    © 2022 - 2024 — McMap. All rights reserved.