0

The following build.gradle code for my main or launcher module is not updating the versionCode to 2. When I try to update the apk in Google Play the website tells me the apk uploaded is still version 1. Anyone knows what the problem is? I did download and modify some existing code, so I'm not aware of all the build scripts. I'm not looking to auto increment the version code. At line 24 I code versionCode 2.

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}

apply plugin: 'com.android.application'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
         //Keep old ITEC package name as application Id for Play Store compatibility
//        applicationId 'at.aau.itec.android.mediaplayerdemo'
//        applicationId "com.gregmarsh.AndroidVideoCapture.VideoMetronome"
        applicationId "com.gregmarsh.AndroidVideoCapture.WCSDanceOnTimePro"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 2
        versionName '1.1'
//        versionCode 3
//        versionName "1.2"

//        //applicationId "com.exercise.com.exercise.AndroidVideoCapture.AndroidVideoCapture"
//        applicationId "com.gregmarsh.AndroidVideoCapture.VideoMetronome"
//        minSdkVersion 16
//        targetSdkVersion 22
//        // versionCode 1 Name "1.0" 10/28/2015 Initial release
//        // versionCode 2 Name "1.1" 1/4/2016 Recorded video listed in gallery
//        // versionCode 3 Name "1.2" 4/3/2016 Flash & beat sync adjusted, recording stops on phone call.
//        versionCode 3
//        versionName "1.2"

        buildConfigField "boolean", "CRASHLYTICS_CONFIGURED", "${isChrashlyticsConfigured()}"
    }

    signingConfigs {
        debug   // configured in signingconfig.gradle
        release // configured in signingconfig.gradle
    }

    buildTypes {
        debug {
            applicationIdSuffix ".debug"
            versionNameSuffix "-debug"
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.release
        }
    }

    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            if (variant.name == android.buildTypes.release.name) {
                def file = output.outputFile
                def fileName = file.name.replace(".apk", "-" + defaultConfig.versionCode + "-" + defaultConfig.versionName + ".apk")
                output.outputFile = new File(file.parent, fileName)
            }
        }
    }

    lintOptions {
        // Lint fix for Okio: https://github.com/square/okio/issues/58
        warning 'InvalidPackage'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile project(':MediaPlayer')
    compile project(':MediaPlayer-DASH')
    compile('com.crashlytics.sdk.android:crashlytics:2.5.6@aar') {
        transitive = true;
    }
    compile 'com.android.support:appcompat-v7:22.2.1'
}

ext.isLibrary = false
apply from: "../gitversioning.gradle"
apply from: "signingconfig.gradle"

if (isChrashlyticsConfigured()) {
    apply plugin: 'io.fabric'
}

def isChrashlyticsConfigured() {
    return file("fabric.properties").exists()
}
Greg Marsh
  • 209
  • 1
  • 2
  • 9
  • please see this link for help https://stackoverflow.com/questions/21405457/autoincrement-versioncode-with-gradle-extra-properties – Nain Mar 02 '18 at 05:41
  • Possible duplicate of https://stackoverflow.com/questions/17448565/how-to-autoincrement-versioncode-in-android-gradle/33637600 – chb Mar 02 '18 at 05:51
  • Possible duplicate of [How to autoincrement versionCode in Android Gradle](https://stackoverflow.com/questions/17448565/how-to-autoincrement-versioncode-in-android-gradle) – chb Mar 02 '18 at 05:51
  • 1
    Regarding the comments above, I don't think that adding more code you don't understand will improve the situation. Instead try to find out what is going on in the build, start with the `../gitversioning.gradle` script. – Henry Mar 02 '18 at 05:54
  • From Henry's comment it appears ../gitversioning.gradle is changing the versionCode back to 1. I'm thinking commenting out apply from: "../gitversioning.gradle" and apply from: "signingconfig.gradle" lines. – Greg Marsh Mar 03 '18 at 03:25
  • Post your gitversioning.gradle – Gabriele Mariotti Mar 03 '18 at 07:29
  • Issue solved by removing line apply from: "../gitversioning.gradle" and manually changing the version code. Thanks Henry and Gabriele – Greg Marsh Mar 04 '18 at 19:20
  • Please visit this link for help https://stackoverflow.com/a/57100212/8788194 – rkmsnc Jul 20 '19 at 13:41

0 Answers0