3.8 KiB
3.8 KiB
Google Play Publishing Setup
This guide explains how to configure the Triple-T gradle-play-publisher plugin for automated Google Play Store deployments.
Prerequisites
- A Google Play Developer account
- An app already created in the Google Play Console
- A service account with appropriate permissions
Creating a Service Account
- Go to the Google Play Console
- Navigate to Setup → API access
- Click Create new service account
- Follow the link to Google Cloud Console
- Create a new service account with an appropriate name (e.g.,
waterfox-android-publisher
) - Grant the service account the Service Account User role
- Create and download a JSON key for the service account
- Back in Play Console, grant the service account appropriate permissions:
- Release management (to upload APKs/AABs)
- Production release (to promote to production)
- Any other tracks you want to deploy to
Configuration Methods
Method 1: Environment Variable (Recommended for CI/CD)
Set the ANDROID_PUBLISHER_CREDENTIALS
environment variable with the entire JSON content:
export ANDROID_PUBLISHER_CREDENTIALS=$(cat /path/to/service-account.json)
For GitHub Actions:
env:
ANDROID_PUBLISHER_CREDENTIALS: ${{ secrets.PLAY_PUBLISHER_CREDENTIALS }}
Method 2: File Path (Local Development)
You can also specify a file path in your local.properties
or as a Gradle property:
playPublisher.serviceAccountJson=/path/to/service-account.json
Or via command line:
./gradlew publishReleaseBundle -PplayPublisher.serviceAccountJson=/path/to/service-account.json
Method 3: Play Console API Key (Legacy)
If using an API key instead of service account:
export ANDROID_PUBLISHER_CREDENTIALS='{"type":"api_key","key":"YOUR_API_KEY"}'
Usage
Publishing to Production
./gradlew publishReleaseBundle
Publishing to Beta Track
./gradlew publishReleaseBundle --track=beta
Publishing to Internal Testing
./gradlew publishReleaseBundle --track=internal
Uploading Without Publishing
./gradlew uploadReleaseBundle
Advanced Configuration
Add to app/build.gradle
for more control:
play {
serviceAccountCredentials.set(file("path/to/service-account.json"))
defaultToAppBundles.set(true)
track.set("internal") // Default track
releaseStatus.set(ReleaseStatus.DRAFT)
userFraction.set(0.1) // For staged rollouts
}
Security Best Practices
-
Never commit credentials to version control
- The
.gitignore
is already configured to exclude common credential files
- The
-
Use environment variables in CI/CD
- Store credentials as encrypted secrets in your CI/CD platform
-
Rotate service account keys regularly
- Create new keys periodically and revoke old ones
-
Use minimal permissions
- Only grant the service account the permissions it needs
Troubleshooting
"401 Unauthorized" Error
- Verify the service account has been granted permissions in Play Console
- Ensure the JSON credentials are valid and not expired
"Package name not found" Error
- Confirm the
applicationId
inbuild.gradle
matches your Play Store app - Ensure the app has been created in Play Console first
"Version code already exists" Error
- The version code must be higher than any previously uploaded version
- Check your version code generation logic