What You'll Create
- Android Keystore file (
.keystoreor.jks) - Google Play Service Account JSON
Konten ini belum tersedia dalam bahasa Anda.
Complete guide to creating the Android signing keystore and Google Play service account required for building and publishing Android apps with Capgo Cloud Build.
To build and publish Android apps, you need:
.keystore or .jks file) - Signs your app for release.json file) - For automatic Play Store uploadsWhat You'll Create
.keystore or .jks)Requirements
The keystore contains your private key used to sign your Android app. Every update to your app on the Play Store must be signed with the same key.
The keytool command is included with Java JDK. Open your terminal:
keytool -genkey -v \ -keystore my-release-key.keystore \ -alias my-key-alias \ -keyalg RSA \ -keysize 2048 \ -validity 10000You’ll be prompted for:
| Prompt | Description | Example |
|---|---|---|
| Keystore password | Password to open the keystore file | MySecurePassword123! |
| Key password | Password for this specific key (can be same as keystore) | MySecurePassword123! |
| First and last name | Your name or company name | John Doe |
| Organizational unit | Department (optional) | Mobile Development |
| Organization | Company name | My Company Inc. |
| City | Your city | San Francisco |
| State | Your state/province | California |
| Country code | Two-letter country code | US |
After completing the prompts, you’ll have a my-release-key.keystore file.
Open Android Studio
Open any project or create a new one.
Open the Build menu
Go to Build → Generate Signed Bundle / APK
Choose APK or Bundle
Select Android App Bundle or APK and click Next.
Create new keystore
Click “Create new…” to create a new keystore.
Fill in keystore details
.jks filerelease-key)Complete the wizard
Click OK to create the keystore, then finish or cancel the build wizard.
When saving credentials for Capgo, you’ll need these values:
| Value | Environment Variable | Description |
|---|---|---|
| Keystore file | ANDROID_KEYSTORE_FILE | Base64-encoded keystore file |
| Keystore password | KEYSTORE_STORE_PASSWORD | Password to open the keystore |
| Key alias | KEYSTORE_KEY_ALIAS | Name of your key in the keystore |
| Key password | KEYSTORE_KEY_PASSWORD | Password for the specific key |
Check that your keystore was created correctly:
# List all keys in the keystorekeytool -list -keystore my-release-key.keystore
# View detailed information about a specific keykeytool -list -v -keystore my-release-key.keystore -alias my-key-aliasYou should see output showing your certificate details and expiration date.
A service account allows Capgo to automatically upload your app to the Google Play Store.
Open Google Play Console
Go to Google Play Console and sign in.
Navigate to API Access
In the left sidebar, go to Setup → API access.
Create a new service account
In the “Service accounts” section, click “Create new service account”.
A dialog will appear with a link to Google Cloud Console.
Create the account in Google Cloud
Click the link to open Google Cloud Console in a new tab.
In Google Cloud Console:
capgo-play-upload)Service account for Capgo CI/CD uploads)Skip the optional role assignment
You don’t need to assign Google Cloud roles here. Click “Continue”, then “Done”.
Create a JSON key
Find your new service account in the list and click on it.
Go to the “Keys” tab:
The JSON file will download automatically. Keep this file secure!
Grant Play Console permissions
Go back to Google Play Console (the tab from step 3).
Click “Refresh service accounts” or refresh the page.
Find your new service account in the list and click “Manage Play Console permissions” (or “Grant access”).
Set app permissions
On the permissions page:
Under “App permissions”:
Under “Account permissions” (for the app you selected):
Click “Invite user”.
Verify the invitation
The service account should now appear in your users list with the permissions you granted.
Your service account needs these minimum permissions:
| Permission | Required For |
|---|---|
| Create, edit, and delete draft releases | Uploading new versions |
| Release to production, exclude devices, and use Play App Signing | Publishing to any track |
| Release apps to testing tracks | Publishing to internal/alpha/beta |
Now save your credentials for use with Capgo Cloud Build:
npx @capgo/cli build credentials save \ --platform android \ --keystore ./my-release-key.keystore \ --keystore-alias "my-key-alias" \ --keystore-key-password "YourKeyPassword" \ --keystore-store-password "YourStorePassword" \ --play-config ./play-store-service-account.jsonFor CI/CD environments, encode files as base64 and set environment variables:
# Encode keystore to base64base64 -i my-release-key.keystore | pbcopy
# Encode service account JSON to base64base64 -i play-store-service-account.json | pbcopySet these environment variables in your CI/CD secrets:
| Variable | Description |
|---|---|
ANDROID_KEYSTORE_FILE | Base64-encoded keystore file |
KEYSTORE_KEY_ALIAS | Key alias name in the keystore |
KEYSTORE_KEY_PASSWORD | Password for the key |
KEYSTORE_STORE_PASSWORD | Password for the keystore (optional if same as key password) |
PLAY_CONFIG_JSON | Base64-encoded service account JSON |
Test that everything is configured correctly:
# List saved credentialsnpx @capgo/cli build credentials list
# Run a debug build (no signing required)npx @capgo/cli build com.example.app --platform android --build-mode debug
# Run a release build (requires signing)npx @capgo/cli build com.example.app --platform android --build-mode releaseGoogle Play App Signing is recommended for enhanced security. When enabled:
This is configured in the Play Console under Setup → App signing and doesn’t change how you use Capgo - you still provide your upload keystore.
Cause: Incorrect path to keystore file.
Solution: Verify the file path is correct and the file exists:
ls -la ./my-release-key.keystoreCause: Wrong password entered.
Solution:
KEYSTORE_STORE_PASSWORD: Opens the keystore fileKEYSTORE_KEY_PASSWORD: Accesses the specific keyTest with keytool:
keytool -list -keystore my-release-key.keystore# Enter store password when promptedCause: Key alias name doesn’t match.
Solution: List all aliases in your keystore:
keytool -list -keystore my-release-key.keystoreThe alias is case-sensitive - use it exactly as shown.
Cause: Service account permissions issue.
Solution:
Cause: Signing with a different key than previous releases.
Solution:
Never commit to version control
# Add to .gitignoreecho "*.keystore" >> .gitignoreecho "*.jks" >> .gitignoreCreate backups
Use strong passwords
Limit permissions
Never commit JSON to version control
echo "*-service-account.json" >> .gitignoreRotate if compromised