generate-apk
v1.1.0
Published
CLI tool to convert .aab to .apk via BundleTool, with prompts and signing.
Maintainers
Readme
📦 generate-apk
A powerful and user-friendly Node.js CLI tool to convert Android App Bundles (AAB) to APKs using Google's BundleTool, with interactive prompts and automatic keystore management.
✨ Features
- 🚀 Two modes: Interactive and automated build mode
- 📥 Automatic BundleTool download - no manual setup required
- 🔐 Automatic keystore creation - generates signed APKs ready for distribution
- 🎯 Smart AAB detection - finds
.aabfiles automatically - 📋 Interactive prompts with sensible defaults
- 🛡️ Universal APK generation compatible with all devices
- 🎨 Beautiful CLI interface with emojis and clear feedback
- ⚡ Cross-platform support (Windows, macOS, Linux)
- 📁 Organized output - uses dedicated build folder on desktop
- 🔧 CI/CD friendly - scriptable build mode
📦 Installation
Global Installation (Recommended)
npm install -g generate-apkLocal Installation
npm install generate-apk
npx generate-apk🚀 Quick Start
Interactive Mode
Navigate to a directory containing your .aab file and run:
generate-apkWhat it does:
- 📥 Downloads BundleTool automatically (if not present)
- 🔍 Detects
.aabfiles in your directory - 🔐 Prompts for keystore details or creates one automatically
- ⚙️ Generates signed APK with your specified name
Build Mode (Automated)
For automated workflows and CI/CD:
generate-apk build <file.aab> --name=<output.apk>What it does:
- 📁 Uses/creates
buildfolder on desktop - 🔑 Creates keystore automatically (no prompts)
- ⚙️ Generates signed APK with default settings
- 📱 Ready for distribution
🛠️ Usage Examples
Interactive Mode Examples
# Basic usage - finds .aab files automatically
generate-apk
# Direct file specification
generate-apk app-release.aabInteractive workflow:
$ generate-apk
✅ Found bundletool-all-1.18.1.jar
⚙️ Only one .aab found, using app-release.aab
🔐 Signing setup (press Enter for defaults or "skip" for unsigned)
Keystore path [chatreal-release.keystore] or "skip":
📋 Keystore not found. Create new keystore? (Y/n): y
🔑 Creating keystore...
✅ Keystore created: chatreal-release.keystore
🔧 Building signed APKS from app-release.aab…
📦 Extracting universal.apk…
Enter final APK name [app-release-signed.apk]: MyApp-v1.2.3.apk
✅ APK ready: MyApp-v1.2.3.apkBuild Mode Examples
# Basic build command
generate-apk build app-release.aab --name=myapp.apk
# Multiple APKs (all go to same build folder)
generate-apk build app-release.aab --name=release.apk
generate-apk build app-debug.aab --name=debug.apkBuild mode workflow:
$ generate-apk build app-release.aab --name=myapp.apk
📁 Using existing build directory: /home/user/Desktop/build
✅ Found bundletool-all-1.18.1.jar
✅ Found keystore: release.keystore
🔧 Building signed APKS from app-release.aab...
📦 Extracting universal.apk...
✅ APK conversion completed!
📱 APK file: myapp.apk (signed)
📁 Location: /home/user/Desktop/build
🔐 Signed with keystore: release.keystore
💡 Your signed APK is ready for distribution and installation!⚙️ Command Reference
Interactive Mode
generate-apk # Auto-detect AAB files
generate-apk <file.aab> # Specify AAB file
generate-apk --help # Show helpBuild Mode
generate-apk build <file.aab> --name=<output.apk>Build mode features:
- ✅ Uses existing
buildfolder on desktop (creates if needed) - ✅ No interactive prompts - uses defaults
- ✅ Automatically creates and reuses keystore
- ✅ Generates signed APKs ready for distribution
- ✅ Perfect for automation and CI/CD
🔐 Keystore Management
Interactive Mode
- Prompts for keystore path, alias, and passwords
- Can create new keystores with custom details
- Supports existing keystores
- Option to skip signing (unsigned APK)
Build Mode
- Automatically creates
release.keystorein build folder - Uses secure defaults: RSA 2048-bit, 10,000-day validity
- Reuses existing keystore for subsequent builds
- Fallback to unsigned APK if keystore creation fails
Default keystore settings:
- File:
release.keystore - Alias:
release - Store password:
123456 - Key password:
123456
Note: For production apps, consider using custom keystores with stronger passwords.
📁 Project Structure
generate-apk/
├── bin/
│ └── generate-apk.js # 🚀 CLI entry point with command routing
├── lib/
│ ├── index.js # 🛠️ Interactive mode logic
│ ├── build.js # 🏗️ Build mode logic
│ └── utils.js # 🔧 Cross-platform utilities
├── package.json # 📋 Package configuration
└── README.md # 📖 Documentation📋 Output Structure
Interactive Mode
Creates files in current directory:
your-project/
├── app-release.aab # Your input file
├── MyApp-v1.2.3.apk # Generated APK
├── bundletool-all-1.18.1.jar # Downloaded tool
└── chatreal-release.keystore # Created keystoreBuild Mode
Creates organized build folder on desktop:
~/Desktop/build/
├── bundletool-all-1.18.1.jar # Downloaded once, reused
├── release.keystore # Auto-generated keystore
├── myapp.apk # Your signed APKs
├── release.apk # Multiple APKs supported
└── debug.apk # All in one place🔧 Prerequisites
- Node.js 12.0.0 or higher
- Java Runtime Environment (JRE) 8+ for BundleTool and keystore operations
- Android App Bundle (.aab) file
Installing Java (if needed)
Ubuntu/Debian:
sudo apt update && sudo apt install openjdk-11-jdkmacOS:
brew install openjdk@11Windows: Download from Oracle or use OpenJDK
🎯 Advanced Usage
React Native Integration
# Build your React Native app
cd android && ./gradlew bundleRelease
# Convert to APK
cd app/build/outputs/bundle/release
generate-apk build app-release.aab --name=MyApp-v1.0.0.apkCI/CD Integration
# GitHub Actions example
- name: Convert AAB to APK
run: |
npm install -g generate-apk
generate-apk build app/build/outputs/bundle/release/app-release.aab --name=release.apkPackage.json Scripts
{
"scripts": {
"build-apk": "generate-apk build android/app/build/outputs/bundle/release/app-release.aab --name=myapp.apk",
"build-apk-interactive": "generate-apk"
}
}🐛 Troubleshooting
Common Issues
"No .aab files found"
- Ensure you're in the correct directory
- Check that your file has the
.aabextension - Use direct file path:
generate-apk my-app.aab
"java: command not found"
- Install Java JDK/JRE 8 or higher
- Ensure
javaandkeytoolare in your system PATH - Test with:
java -versionandkeytool -help
"keytool: command not found"
- Install Java JDK (not just JRE)
- On some systems:
sudo apt install openjdk-11-jdk
Permission denied (Linux/macOS)
- Run:
chmod +x ./bin/generate-apk.js - Or install globally:
npm install -g generate-apk
PowerShell errors (Windows)
- Ensure PowerShell execution policy allows scripts
- Run PowerShell as administrator if needed
Debug Information
The tool provides detailed feedback at each step:
- ✅ Success indicators
- 📥 Download progress
- 🔧 Build process status
- ⚠️ Warning messages
- ❌ Clear error descriptions
🔄 Version History
- v1.1.0: Added build mode, cross-platform unzip, automatic keystore creation
- v1.0.0: Initial release with interactive mode
🙏 Acknowledgments
- Google BundleTool - The official tool for Android App Bundle operations
- Android Developer Community - For feedback and feature requests
- Node.js Community - For the excellent ecosystem
📞 Support
- 🐛 Issues: GitHub Issues
- 📧 Email: [email protected]
⭐ If this tool helped you, please give it a star on GitHub! ⭐
Made with ❤️ by Shaurya Gupta
