0
votes

I changed versionCode from 1.0 to 1.1 like this:

versionCode 1.1
versionName "1.1"

And now I can't sync the project because it is giving me this error:

Caused by: org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method versionCode() for arguments [1.1] on DefaultConfig_Decorated{name=main, dimension=null, minSdkVersion=DefaultApiVersion{mApiLevel=16, mCodename='null'}, targetSdkVersion=DefaultApiVersion{mApiLevel=28, mCodename='null'}, renderscriptTargetApi=null, renderscriptSupportModeEnabled=null, renderscriptSupportModeBlasEnabled=null, renderscriptNdkModeEnabled=null, versionCode=1, versionName=1.10.1, applicationId=com.github.fahadmaqsood.likhat, testApplicationId=null, testInstrumentationRunner=android.support.test.runner.AndroidJUnitRunner, testInstrumentationRunnerArguments={}, testHandleProfiling=null, testFunctionalTest=null, signingConfig=null, resConfig=null, mBuildConfigFields={CRASH_REPORT_EMAIL_ADDRESS=com.android.builder.internal.ClassFieldImpl@b2244504}, mResValues={}, mProguardFiles=[], mConsumerProguardFiles=[], mManifestPlaceholders={}, mWearAppUnbundled=null} of type com.android.build.gradle.internal.dsl.DefaultConfig.

2
version code cannot be 1.1. It should always be an intNongthonbam Tonthoi
So I should change versionCode to 2?user13348270
Yes you should increment it by 1Nongthonbam Tonthoi
See here for more infoNongthonbam Tonthoi
@NongthonbamTonthoi thanks, it worked!user13348270

2 Answers

6
votes

From the official docs, the version code must be a positive integer.

It is usually incremented by 1 every time there is an update.

2
votes

You cannot add a Float value as the VersionCode. Because, the version code accepts only positive Integer digits as a valid Version code.

As per the official documentation:

versionCode — A positive integer used as an internal version number. This number is used only to determine whether one version is more recent than another, with higher numbers indicating more recent versions. This is not the version number shown to users; that number is set by the versionName setting, below. The Android system uses the versionCode value to protect against downgrades by preventing users from installing an APK with a lower versionCode than the version currently installed on their device.

The value is a positive integer so that other apps can programmatically evaluate it, for example to check an upgrade or downgrade relationship. You can set the value to any positive integer you want, however you should make sure that each successive release of your app uses a greater value. You cannot upload an APK to the Play Store with a versionCode you have already used for a previous version.

Official Documentation Version Link