expo-keystore-manager
v1.0.2
Published
A comprehensive Expo config plugin for managing Android release keystore configuration
Maintainers
Readme
Expo Release Keystore Manager Plugin
A comprehensive Expo config plugin for managing Android release keystore configuration. This plugin automates the setup of release signing, ProGuard/R8 optimization, and keystore validation for your Expo/React Native Android apps.
Features
- 🔐 Complete Keystore Configuration: Automatically configures Gradle properties and build scripts
- ✅ Validation: Validates keystore configuration and file existence
- 🛡️ ProGuard/R8 Support: Optional code obfuscation and optimization
- 🔧 Flexible Configuration: Supports JKS, PKCS12, and BKS keystore types
- 📝 Detailed Logging: Clear feedback during configuration process
- 🛠️ Utility Functions: Helper functions for keystore management
Installation
npm install expo-keystore-manager
# or
yarn add expo-keystore-managerUsage
Basic Configuration
Add the plugin to your app.json or app.config.js:
{
"expo": {
"plugins": [
[
"expo-keystore-manager",
{
"keystoreFile": "./android/app/my-release-key.keystore",
"keystorePassword": "your-keystore-password",
"keyAlias": "my-key-alias",
"keyPassword": "your-key-password"
}
]
]
}
}Advanced Configuration
{
"expo": {
"plugins": [
[
"expo-keystore-manager",
{
"keystoreFile": "./android/app/my-release-key.keystore",
"keystorePassword": "your-keystore-password",
"keyAlias": "my-key-alias",
"keyPassword": "your-key-password",
"storeType": "JKS",
"enableProguard": true,
"enableR8": true,
"customProguardRules": "-keep class com.myapp.** { *; }"
}
]
]
}
}Configuration Options
| Option | Type | Required | Default | Description |
| --------------------- | ------- | -------- | ------- | -------------------------------- |
| keystoreFile | string | ✅ | - | Path to your keystore file |
| keystorePassword | string | ✅ | - | Password for the keystore |
| keyAlias | string | ✅ | - | Alias of the key in the keystore |
| keyPassword | string | ✅ | - | Password for the key |
| storeType | string | ❌ | "JKS" | Keystore type (JKS, PKCS12, BKS) |
| enableProguard | boolean | ❌ | true | Enable ProGuard/R8 minification |
| enableR8 | boolean | ❌ | true | Enable R8 optimization |
| customProguardRules | string | ❌ | - | Custom ProGuard rules to add |
Security Best Practices
Environment Variables
For security, use environment variables instead of hardcoding sensitive values:
// app.config.js
export default {
expo: {
plugins: [
[
"expo-keystore-manager",
{
keystoreFile: process.env.KEYSTORE_FILE,
keystorePassword: process.env.KEYSTORE_PASSWORD,
keyAlias: process.env.KEY_ALIAS,
keyPassword: process.env.KEY_PASSWORD,
},
],
],
},
};Password Strength
The plugin includes password validation. Ensure your passwords:
- Are at least 8 characters long
- Contain at least 3 of: uppercase, lowercase, numbers, special characters
Creating a Keystore
If you don't have a keystore yet, you can create one using the keytool command:
keytool -genkeypair -v -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 -alias my-key-alias -keystore my-release-key.keystoreThe plugin also provides a utility function to generate this command:
const { utils } = require("expo-keystore-manager");
const command = utils.generateKeytoolCommand({
keystoreFile: "my-release-key.keystore",
keyAlias: "my-key-alias",
storeType: "JKS",
validity: 10000,
keySize: 2048,
algorithm: "RSA",
});
console.log("Run this command to create your keystore:");
console.log(command);What the Plugin Does
- Validates Configuration: Checks that all required fields are provided and validates password strength
- Sets Gradle Properties: Adds keystore configuration to
gradle.properties - Configures Build Script: Modifies
app/build.gradleto use the signing configuration - Sets up ProGuard: Creates default ProGuard rules and enables minification (if enabled)
- Provides Feedback: Logs progress and any issues during configuration
Gradle Properties Added
The plugin adds these properties to your gradle.properties:
MYAPP_RELEASE_STORE_FILE=path/to/your/keystore
MYAPP_RELEASE_KEY_ALIAS=your-key-alias
MYAPP_RELEASE_STORE_PASSWORD=your-keystore-password
MYAPP_RELEASE_KEY_PASSWORD=your-key-password
MYAPP_RELEASE_STORE_TYPE=JKSBuild Script Modifications
The plugin modifies your android/app/build.gradle to include:
android {
signingConfigs {
release {
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
storeType MYAPP_RELEASE_STORE_TYPE
}
}
}
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}Troubleshooting
Common Issues
- Keystore file not found: Ensure the path in
keystoreFileis correct relative to your project root - Build fails with signing errors: Verify your keystore password and key alias are correct
- ProGuard issues: Check the generated
proguard-rules.profile and add custom rules if needed
Debug Mode
The plugin provides detailed logging. Check your terminal output when running expo prebuild for configuration details.
Utility Functions
The plugin exports utility functions for advanced usage:
const { utils } = require("expo-keystore-manager");
// Generate keystore configuration template
const template = utils.generateKeystoreTemplate("MyApp");
// Validate password strength
const validation = utils.validatePasswordStrength("mypassword");
// Generate keytool command
const command = utils.generateKeytoolCommand(config);
// Sanitize config for logging (hides passwords)
const sanitized = utils.sanitizeConfigForLogging(config);License
MIT
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
