Encountering and resolving an error when building for Android platforms where the versioning is too long.


Building for Android

Ren’Py can conveniently build towards many platforms with the click of a couple buttons. There’s no need to launch Android Studio (or your Android development editor of choice) or some Java compiler just to build the game to work on Android platforms.

While working on updating some builds, we decided to encode information about the specific build directly into the version number for the build. Version 1.07.7.2.2.491.1 can be understood as

But when trying to build the game, we received this ~mysterious~ Java error.

Updating project.

Creating assets directory.

Packaging internal data.

I'm using Gradle to build the package.
Unable to find a $JAVA_HOME at "/usr", continuing with system-provided Java...
Starting a Gradle Daemon (subsequent builds will be faster)

FAILURE: Build failed with an exception.

* Where:
Build file '/Applications/renpy-7.0.0-sdk/rapt/project/app/build.gradle' line: 17

* What went wrong:
A problem occurred evaluating project ':app'.
> Could not find method versionCode() for arguments [10707020691] on DefaultConfig_Decorated{name=main, dimension=null, minSdkVersion=DefaultApiVersion{mApiLevel=19, mCodename='null'}, targetSdkVersion=DefaultApiVersion{mApiLevel=28, mCodename='null'}, renderscriptTargetApi=null, renderscriptSupportModeEnabled=null, renderscriptSupportModeBlasEnabled=null, renderscriptNdkModeEnabled=null, versionCode=null, versionName=null, applicationId=com.argentgames.chessofblades.demo, testApplicationId=null, testInstrumentationRunner=null, testInstrumentationRunnerArguments={}, testHandleProfiling=null, testFunctionalTest=null, signingConfig=null, resConfig=null, mBuildConfigFields={}, mResValues={}, mProguardFiles=[], mConsumerProguardFiles=[], mManifestPlaceholders={}, mWearAppUnbundled=null} of type com.android.build.gradle.internal.dsl.DefaultConfig.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org/

BUILD FAILED in 7s

What does Could not find method versionCode() for arguments [10707020691] mean? No idea, but something is wrong with the version number, so we’ll just try making it shorter…something like: Version 1.07.722.1

Which seems to build just fine.