user13348270
user13348270

Reputation:

Could not find method versionCode() for arguments [1.1]

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.

Upvotes: 1

Views: 4773

Answers (2)

Nongthonbam Tonthoi
Nongthonbam Tonthoi

Reputation: 12953

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

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

Upvotes: 9

Prajwal Waingankar
Prajwal Waingankar

Reputation: 2710

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

Upvotes: 3

Related Questions