App signing, Play Console setup, and release management for production apps.
App Signing Overview
# Signing Process
1. Generate upload key (keystore)
2. Sign app bundle (AAB) with upload key
3. Upload to Play Console
4. Google manages app signing key (Play App Signing)
5. Google re-signs and distributes
# Key Concepts
- Upload Key: Your key, used to sign AAB before upload
- App Signing Key: Google's key, used to sign APKs for users
- Play App Signing: Google manages app signing key (recommended)
- Legacy: You manage both keys (not recommended)Generate Upload Keystore
# Generate upload keystore (keep secure!)
keytool -genkeypair -v \
-keystore upload.keystore \
-alias upload \
-keyalg RSA \
-keysize 2048 \
-validity 10000 \
-storepass <strong-password> \
-keypass <strong-password> \
-dname "CN=Your Name, OU=Android, O=Your Company, L=City, S=State, C=US"
# Verify keystore
keytool -list -v -keystore upload.keystore -alias upload
# Export certificate for Play Console (if not using Play App Signing)
keytool -export -rfc \
-keystore upload.keystore \
-alias upload \
-file upload_certificate.pemConfigure Signing in Gradle
// build.gradle.kts (app)
android {
signingConfigs {
create("release") {
// Load from local.properties or environment
val storeFile = project.rootProject.file("upload.keystore")
storeFile = storeFile
storePassword = project.findProperty("UPLOAD_STORE_PASSWORD")?.toString() ?: ""
keyAlias = "upload"
keyPassword = project.findProperty("UPLOAD_KEY_PASSWORD")?.toString() ?: ""
}
create("debug") {
storeFile = file("../debug.keystore")
storePassword = "android"
keyAlias = "androiddebugkey"
keyPassword = "android"
}
}
buildTypes {
release {
signingConfig = signingConfigs.getByName("release")
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
debug {
signingConfig = signingConfigs.getByName("debug")
isMinifyEnabled = false
isDebuggable = true
}
}
}local.properties (Not Committed)
# local.properties - NEVER commit this file!
UPLOAD_STORE_PASSWORD=your_keystore_password
UPLOAD_KEY_PASSWORD=your_key_password# Add to .gitignore
echo "local.properties" >> .gitignore
echo "*.keystore" >> .gitignore
echo "*.jks" >> .gitignorePlay Console Setup
# 1. Create Play Console Account
- Go to play.google.com/console
- Pay $25 one-time registration fee
- Complete developer profile
# 2. Create App
- Click "Create app"
- Enter app name, default language
- Choose app or game
- Free or paid
# 3. Set Up App Signing (Play App Signing - Recommended)
- Go to Setup → App integrity → App signing
- Choose "Let Google manage and protect your app signing key"
- Upload your upload certificate (upload_certificate.pem)
- OR: Generate new upload key in Play Console
# 4. Configure Store Listing
- Main store listing (title, descriptions, graphics)
- Screenshots (phone, tablet, Wear, TV)
- Feature graphic, icon, promo video
- Privacy policy URLBuild Release AAB
# Build release bundle
./gradlew bundleRelease
# Output: app/build/outputs/bundle/release/app-release.aab
# Verify bundle
bundletool validate --bundle=app/build/outputs/bundle/release/app-release.aab
# Check signing
./gradlew signingReportUpload to Play Console
# Internal Testing (Fast, up to 100 testers)
1. Go to Testing → Internal testing
2. Create new release
3. Upload AAB
4. Add release name and notes
5. Save → Review → Rollout to internal testing
6. Share join link with testers
# Closed Testing (Alpha/Beta)
1. Go to Testing → Closed testing
2. Create track (Alpha, Beta, or custom)
3. Add testers (email lists, Google Groups)
4. Upload AAB
5. Rollout percentage (10%, 50%, 100%)
# Open Testing
1. Go to Testing → Open testing
2. Anyone can join
3. Good for public beta
# Production
1. Go to Testing → Production
2. Create release
3. Upload AAB
4. Set rollout percentage (start with 10-20%)
5. Monitor crash rates, ANRs
6. Increase rollout graduallyRelease Management
# Release naming convention
# Format: v{major}.{minor}.{patch}-{buildType}-{flavor}
# Examples:
# v1.0.0-release-premium
# v1.2.3-staging-free
# v2.0.0-rc1-enterprise
# Release notes template
## What's New
### Features
- New feature description
### Improvements
- Performance improvement
### Bug Fixes
- Fixed crash on login
### Known Issues
- Issue description (if any)Play App Signing Details
# How Play App Signing Works
1. You generate upload key (keystore)
2. You sign AAB with upload key
3. Upload to Play Console
4. Google verifies upload key matches registered certificate
5. Google removes your signature
6. Google signs with app signing key (stored in Google's HSM)
7. Google generates optimized APKs for each device
8. Users download APKs signed by Google
# Benefits
- Key stored in Google's hardware security modules
- Lost upload key → reset in Play Console (contact support)
- Dynamic delivery (smaller downloads)
- Protection against key compromise
- Automatic key rotation (future)
# If You Lose Upload Key
1. Go to Play Console → Setup → App integrity → App signing
2. Click "Request upload key reset"
3. Generate new upload key locally
4. Upload new certificate
5. Google verifies and switchesTesting Before Release
# Install internal test build locally
./gradlew installInternalDebug
# Test specific variant
./gradlew installFreeRelease
# Generate APKs from AAB for testing
bundletool build-apks \
--bundle=app/build/outputs/bundle/release/app-release.aab \
--output=app.apks \
--ks=upload.keystore \
--ks-pass=pass:<password> \
--ks-key-alias=upload \
--key-pass=pass:<password>
# Install on device
bundletool install-apks --apks=app.apksProGuard/R8 Configuration
# proguard-rules.pro
# Keep application class
-keep public class com.example.myapp.MyApplication
# Keep Hilt generated classes
-keep class dagger.hilt.** { *; }
-keep class * extends dagger.hilt.android.HiltAndroidApp { *; }
# Keep Room entities
-keep class com.example.myapp.data.** { *; }
# Keep Parcelable implementations
-keep class * implements android.os.Parcelable {
public static final ** CREATOR;
}
# Keep Enum values
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
# Keep Serialization
-keep class kotlinx.serialization.** { *; }
-keep @kotlinx.serialization.Serializable class * { *; }
# Keep Retrofit
-dontwarn retrofit2.**
-keep class retrofit2.** { *; }
-keepattributes Signature
-keepattributes *Annotation*
# Keep OkHttp
-dontwarn okhttp3.**
-keep class okhttp3.** { *; }
# Keep Coroutines
-dontwarn kotlinx.coroutines.**
-keep class kotlinx.coroutines.** { *; }
# Keep Compose
-keep class androidx.compose.** { *; }
# Remove logging in release
-assumenosideeffects class android.util.Log {
public static *** d(...);
public static *** v(...);
public static *** i(...);
}Version Code Strategy
// build.gradle.kts
android {
defaultConfig {
// Base version code
versionCode = 1000000 // 1.0.0 = 1,000,000
versionName = "1.0.0"
}
// Per variant version codes
applicationVariants.all { variant ->
def baseCode = defaultConfig.versionCode
def flavorCode = 0
def buildTypeCode = 0
// Flavor offsets
when (variant.flavorName) {
"free" -> flavorCode = 0
"premium" -> flavorCode = 10000
"enterprise" -> flavorCode = 20000
}
// Build type offsets
when (variant.buildType.name) {
"debug" -> buildTypeCode = 1000000
"staging" -> buildTypeCode = 2000000
"release" -> buildTypeCode = 0
}
def variantCode = baseCode + flavorCode + buildTypeCode
variant.outputs.all {
versionCodeOverride = variantCode
}
}
}Pre-Launch Report
# Pre-Launch Report (Automatic)
- Runs on Firebase Test Lab
- Tests on multiple devices/API levels
- Checks:
- Crashes and ANRs
- Performance issues
- Security vulnerabilities
- Accessibility issues
- Compatibility problems
# View Report
- Go to Testing → Pre-launch report
- Review issues before rolling out
- Fix critical crashes before productionPlay Console API (Automation)
# Python script for automated uploads
from googleapiclient.discovery import build
from google.oauth2 import service_account
SCOPES = ['https://www.googleapis.com/auth/androidpublisher']
SERVICE_ACCOUNT_FILE = 'play-console-key.json'
credentials = service_account.Credentials.from_service_account_file(
SERVICE_ACCOUNT_FILE, scopes=SCOPES)
service = build('androidpublisher', 'v3', credentials=credentials)
package_name = 'com.example.myapp'
# Create edit
edit_request = service.edits().insert(body={}, packageName=package_name)
edit = edit_request.execute()
edit_id = edit['id']
# Upload bundle
media = MediaFileUpload('app-release.aab', mimetype='application/octet-stream')
bundle_response = service.edits().bundles().upload(
editId=edit_id,
packageName=package_name,
media_body=media
).execute()
version_code = bundle_response['versionCode']
# Assign to track
track_response = service.edits().tracks().update(
editId=edit_id,
track='internal',
packageName=package_name,
body={
'releases': [{
'versionCodes': [str(version_code)],
'status': 'completed',
'releaseNotes': [{
'language': 'en-US',
'text': 'Bug fixes and improvements'
}]
}]
}
).execute()
# Commit edit
service.edits().commit(editId=edit_id, packageName=package_name).execute()
print(f"Uploaded version {version_code} to internal track")Try It
Generate upload keystore. Configure signing in Gradle. Create Play Console account. Set up Play App Signing. Build release AAB. Upload to internal testing. Create production release with rollout.
# Build release
./gradlew bundleRelease
# Verify signing
./gradlew signingReportSigning & Release mastery
- Generate upload keystore with strong passwords
- Configure release signing in Gradle (local.properties)
- Set up Play Console account and app
- Enable Play App Signing
- Build and verify release AAB
- Upload to internal testing track
- Create closed testing track with testers
- Create production release with 10% rollout
- Monitor pre-launch report
- Implement version code strategy
Generate upload keystore (keep secure!). Configure Gradle signing with local.properties. Play App Signing: Google manages app signing key. Build AAB with ./gradlew bundleRelease. Upload to tracks: internal → closed → open → production. Use rollout percentages. Monitor pre-launch report.
Resources
- App Signing: https://developer.android.com/studio/publish/app-signing
- Play App Signing: https://support.google.com/googleplay/android-developer/answer/9842756
- Play Console: https://play.google.com/console
- Release Workflow: https://developer.android.com/studio/publish