Before you can publish your app bundles to the play store with this gradle plugin, you have to have:
- A Google Service Account with the rights to publish and modify releases
- Already at least one release done on the track you want to publish to (not covered here)
How to create and configure a service account
The plugin requires the appVersionCode to be defined in the gradle.properties
file in your project.
Per default the key for this is appVersionCode
but you can change it if you want (read below).
Configure the plugin in the app's build.gradle.kts
file.
androidpublisher {
credentialsJsonFile = File("path/to/your/service/account/credentials.json") // <- required: relative or absolute path to the credentials.json file for the service account
releaseNotesFile = File("path/to/your/releaseNotes.csv") // <- optional: relative or absolute path to the releaseNotes.csv file for the service account. Defaults to <projectRootDir>/releaseNotes.csv
shouldThrowIfNoReleaseNotes = true // <- optional, defaults true: defines whether an exception is thrown or not if no releaseNotes for the appVersionCode is found
enableGenerateVersionCode = true // <- optional, defaults true: defines if the appVersionCode should be generated (read below)
appVersionCodeKey = "yourCustomKey" // <- optional, defaults "appVersionCode": key under which the app's version code is stored in the gradle.properties file
createBundleIfNotExists = true // <- optional, defaults true: defines if the upload task should create a bundle in case it does not exist yet
customTracks { // <- optional: lets you define custom tracks to generate deployment tasks for
track("My custom track") // <- optional: defines a custom track named "My custom track" (same name as you gave it in the playstore) with the configuration applied above
track("My custom track with overridden options") { // <- optional: defines a custom track named "My custom track with overridden options" (same name as you gave it in the playstore) with the configuration applied above
releaseNotesFile = File("other/path/to/releaseNotes.csv") // optional: overrides the option "releaseNotesFile" for this track specifically
shouldThrowIfNoReleaseNotes = false // optional: overrides the option "shouldThrowIfNoReleaseNotes" for this track specifically
createBundleIfNotExists = false // optional: overrides the option "createBundleIfNotExists" for this track specifically
}
}
inAppUpdatePriorityProvider = { 5 } // optional: define an in app update priority for this release
}
If you enable the enableGenerateVersionCode
(enabled by default) the app's version code for the playstore gets
autogenerated.
It queries the currently published version code from the playstore and the one you defined in the gradle.properties
and takes the higher one.
It uses this version code +1 and writes it into the gradle.properties
.
Example:
playStoreVersion=23
gradle.properties version=35
results in 35+1 = 36
If you don't want to supply any release notes, you have to set shouldThrowIfNoReleaseNotes
to false. Otherwise it will
throw an exception if no release notes for the versionCode are present.
If you want to specify another location for the releaseNotes csv file or another name, you can set releaseNotesFile
to point to that file.
The format hast to be the following for the spreadsheet which you export as csv to work:
VersionCode | en-gb | de-ch | otherLanguages |
---|---|---|---|
1 | Some release notes in UTF-8 | Some text in german | Other languages text |
2 | Some release notes in UTF-8 | Some text in german | Other languages text |
The plugin creates for each App flavour and build type two gradleTasks: generateVersionCodeForX
and uploadXToYTrack
where X
is your appVersion and Y
is the track in the google play store to where you can publish the app to.
Example:
generateVersionCodeForProductionRelease
uploadProductionReleaseToInternalTrack
These tasks can then be used in your CI/CD setup or triggered manually (as long as the apps signing information is on your local dev machine).
Note:
It is necessary to separate the generateVersionCodeForRelease
task from the uploadReleaseToInternalTrack
task.
Otherwise, gradle can't pick up the changed versionCode