At the moment credentials are validated at the configuration phase of the project. Problem is that one may not want to have serviceAccountCredentials file accessible to everyone and will therefore not be set every time. For example, you don't want to have the file shared among the development team and just have it accessible on CI. Why is this validation not done when credentials actually need to be used?
Don't set play.serviceAccountCredentials property and run ./gradlew tasks. Tasks task has nothing to do with this plugin but it will still fail.
The plugin should validate credentials when they are needed and not at configuration time.
Caused by: java.lang.IllegalStateException: No credentials specified. Please read our docs for more details:
https://github.com/Triple-T/gradle-play-publisher#authenticating-gradle-play-publisher
at com.github.triplet.gradle.play.internal.ValidationKt.validateCreds(Validation.kt:11)
at com.github.triplet.gradle.play.PlayPublisherPlugin$applyInternal$1.execute(PlayPublisherPlugin.kt:141)
at com.github.triplet.gradle.play.PlayPublisherPlugin$applyInternal$1.execute(PlayPublisherPlugin.kt:49)
at org.gradle.internal.ImmutableActionSet$SetWithManyActions.execute(ImmutableActionSet.java:329)
at org.gradle.api.internal.DefaultDomainObjectCollection.doAdd(DefaultDomainObjectCollection.java:264)
at org.gradle.api.internal.DefaultDomainObjectCollection.add(DefaultDomainObjectCollection.java:253)
at com.android.build.gradle.AppExtension.addVariant(AppExtension.java:84)
at com.android.build.gradle.internal.ApiObjectFactory.create(ApiObjectFactory.java:127)
... 146 more
Resolved it by reading documentation all the way through. 馃槃
Resolved it by reading documentation all the way through. 馃槃
On our build server I use an environment variable ANDROID_PUBLISHER_CREDENTIALS, and therefore do not specify serviceAccountCredentials in the gradle file. But in this case all gradle tasks fails when run locally.
Can you be a bit more specific about how you fixed it?
----- EDIT -----
OK, I fixed this by enabling the publisher task using an environment variable only present on the build server.
play {
enabled.set(System.getenv("CI") == "true")
}
What i did was set
play {
isEnabled = false
}
and then added also
android {
playConfigs {
register("<flavourName>") {
isEnabled = project.hasProperty("<gradle_properties_key_for_play_credewntials>")
}
}
}
and since <gradle_properties_key_for_play_credewntials> is only set on CI, it works as expected.
Most helpful comment
Resolved it by reading documentation all the way through. 馃槃