Google Play Store API Setup Guide
Prerequisites
- Google Play Console account with admin access
- Your app published or ready for publishing on Google Play
Step 1: Create Google Cloud Project & Service Account
1.1 Create Google Cloud Project
- Go to Google Cloud Console
- Create a new project or select existing one
- Enable the Google Play Android Developer API:
- Go to “APIs & Services” > “Library”
- Search for “Google Play Android Developer API”
- Click “Enable”
1.2 Create Service Account
- Go to “IAM & Admin” > “Service Accounts”
- Click “Create Service Account”
- Fill in details:
- Name:
fastlane-service-account
- Description:
Service account for Fastlane Google Play Store uploads
- Click “Create and Continue”
- Skip role assignment for now
- Click “Done”
1.3 Create JSON Key
- Find your service account in the list
- Click on it > “Keys” tab
- Click “Add Key” > “Create new key”
- Select “JSON” format
- Download the JSON file (keep it secure!)
Step 2: Grant Permissions in Google Play Console
2.1 Add Service Account to Play Console
- Go to Google Play Console
- Select your app
- Go to “Users and permissions” (left sidebar)
- Click “Invite new users”
- Enter your service account email (from JSON file)
- Grant these permissions:
- ✅ View app information and download bulk reports (read-only)
- ✅ Manage store presence
- ✅ Manage production releases
- ✅ Manage testing tracks
- Click “Send Invitation”
2.2 Accept Invitation
- The service account will receive an email invitation
- Accept it (this is automatic for service accounts)
Step 3: Set Up Environment Variables
3.1 Store JSON Key Securely
# Create a secure directory for keys
mkdir -p ~/.fastlane/keys
# Move your JSON key file there
mv ~/Downloads/your-service-account-key.json ~/.fastlane/keys/play-store-key.json
# Set proper permissions
chmod 600 ~/.fastlane/keys/play-store-key.json
3.2 Set Environment Variable
# Add to your ~/.zshrc or ~/.bashrc
echo 'export GOOGLE_PLAY_JSON_KEY_FILE=~/.fastlane/keys/play-store-key.json' >> ~/.zshrc
# Reload shell
source ~/.zshrc
3.3 Verify Setup
# Check environment variable
echo $GOOGLE_PLAY_JSON_KEY_FILE
# Test Fastlane connection
fastlane run validate_play_store_json_key json_key:~/path/to/your/key.json
Step 4: Test Fastlane Setup
4.1 Test Screenshot Upload
# Upload only screenshots
fastlane android upload_screenshots
4.2 Test Full Upload
# Build, take screenshots, and upload everything
fastlane android build_and_upload
Step 5: Organize Screenshots
5.1 Screenshot Structure
Google Play Store expects screenshots in specific folders:
maestro/screenshots/screenshots/
├── en-US/
│ ├── phoneScreenshots/
│ │ ├── calculator-empty.png
│ │ ├── calculator-bill-entered.png
│ │ └── ...
│ ├── sevenInchScreenshots/
│ └── tenInchScreenshots/
5.2 Organize Your Screenshots
# Create directory structure
mkdir -p maestro/screenshots/screenshots/en-US/phoneScreenshots
# Move screenshots to correct location
mv maestro/screenshots/screenshots/*.png maestro/screenshots/screenshots/en-US/phoneScreenshots/
Troubleshooting
Common Issues:
- “Invalid service account” error
- Check that the service account email is correct
- Ensure the service account has been invited to Play Console
- Wait 24-48 hours after inviting the service account
- “Permission denied” error
- Verify the service account has the correct permissions in Play Console
- Check that the JSON key file path is correct
- “Package name not found” error
- Ensure your app is published or in draft status
- Verify the package name matches exactly
- Screenshot upload issues
- Check screenshot dimensions (required: various sizes)
- Ensure screenshots are in PNG format
- Verify the directory structure matches Play Store requirements
Debug Commands:
# Test JSON key validity
fastlane run validate_play_store_json_key
# Check app details
fastlane run get_google_play_store_app_details
# Verbose output
fastlane android upload_screenshots --verbose
Security Best Practices
- Never commit JSON keys to git
- Add
*.json to .gitignore
- Store keys in secure location (
~/.fastlane/keys/)
- Use environment variables
- Don’t hardcode paths in Fastfile
- Use
ENV["GOOGLE_PLAY_JSON_KEY_FILE"]
- Limit permissions
- Only grant necessary permissions to service account
- Regularly rotate service account keys
Next Steps
Once setup is complete, you can:
- Upload screenshots only:
fastlane android upload_screenshots
- Upload APK + screenshots:
fastlane android upload_all
- Full automated workflow:
fastlane android build_and_upload
Your app screenshots will be uploaded to Google Play Store and ready for review!