Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle DSL method not found when updating application version

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?

    like image 919
    KingoC Avatar asked Jul 02 '15 20:07

    KingoC


    2 Answers

    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'
    
    like image 152
    Gabriele Mariotti Avatar answered Oct 11 '22 13:10

    Gabriele Mariotti


    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!

    like image 36
    Peter P Avatar answered Oct 11 '22 12:10

    Peter P