Bash script to install Cordova Android development environment with all dependencies on Ubuntu 24.04.
We're using it to build android applications on a cheap VPS. According to the algorithm:
- raised the server
- install dependencies
- built the application
- paid off the VPS
Login as root user sudo su
and download bash script:
apt install wget
wget https://gist.githubusercontent.com/zionskynet/0687eb18c50bf12fd02b77c474cfd2b6/raw/1853afae62e363153d8def477bccd630a88e869e/cordova-android-dependencies.sh
Set permissions to execute a bash script:
chmod +x cordova-android-dependencies.sh
Run script:
./cordova-android-dependencies.sh
This will install:
- JAVA 17 (openjdk-17-jdk + openjdk-17-jre)
- Gradle 8.10.2
- sdkmanager "platforms;android-34"
- sdkmanager "build-tools;34.0.0"
- NodeJS 18.xx
- Apache Cordova framework
Bash script contents
Check installed dependencies:
java -version
gradle -v
sdkmanager --help
jarsigner --help
keytool --help
zipalign -v
node -v
cordova -v
The installation script may not work, since everything is constantly changing, updated, and so on. If you experience errors related to Android SDK packages(sdkmanager, jarsigner, keytool, zipalign), let me know in the comments section:)
Why Automate Cordova Android Setup?
Setting up the Android development environment on Ubuntu can be a tedious process. Each dependency — Java, Gradle, Android SDK, and Node.js — requires careful version matching. A bash script simplifies the workflow by automating the installation steps, ensuring compatibility, and saving valuable developer time. This is especially beneficial when working on a low-cost VPS, where every minute counts because the server is billed by usage.
Alternatively you can install Android SDK via Bubblewrap CLI.
VPS vs Local Development
Running Cordova builds on a VPS can offer advantages over local machines. VPS instances often provide more stable resources and can be spun up on demand, while local machines are limited by hardware and may become slow during heavy builds. At the same time, VPS environments bring extra steps such as remote file management and identity verification with providers.
Criteria | Local Machine | VPS Server |
---|---|---|
Setup Speed | Manual installation required | Automated bash script in minutes |
Performance | Depends on your hardware | Scalable CPU/RAM resources |
Cost | Fixed hardware cost | Pay-as-you-go, can shut down after build |
Collaboration | Hard to share environment | Accessible for teams remotely |
Best Practices for Cordova Builds
Once your environment is ready, the focus shifts to building stable and optimized APKs. A good practice is to create release builds with cordova build android --release
, then sign them with jarsigner
and optimize them using zipalign
. Signing and aligning not only makes your apps compliant with Google Play requirements but also reduces file size and improves runtime performance.
- Always test your builds on both emulators and physical devices.
- Keep dependencies up to date to avoid version conflicts with new Android releases.
Alternatives and When to Use Them
Cordova remains a solid choice for hybrid mobile apps, but it is not the only solution. For projects requiring a native-like user experience, Flutter and React Native are often better choices. Meanwhile, Bubblewrap CLI is excellent for converting progressive web apps into Android applications quickly. Choosing the right tool depends on your project goals, budget, and desired performance.
Running Cordova builds on a VPS with this script an excellent compromise between speed and flexibility. Instead of spending hours troubleshooting missing SDK components, you can launch a fresh server, install everything in minutes, build the app, and shut the server down when you're done. For small to medium projects, this workflow pays off the VPS cost immediately.