This site uses cookies to analyse traffic, remember your preferences, and optimise your experience. Learn more, read the privacy policy page.


Cordova - Setup Android SDK on Ubuntu

Cordova - Setup Android SDK on Ubuntu

If you’re looking for a simple instruction on how to run Cordova project for the first time on an Android system, you’ve just found it.

Below I describe the steps to be taken to start building an Android project in Cordova on a clean Ubuntu instance.

Download the latest Android SDK

Download Android SDK command tools

Extract Android SDK

unzip -d ~/Downloads/sdk-tools-linux ~/Downloads/sdk-tools-linux-*.zip

Download the latest Java JDK 8 from Oracle

Download JAVA JDK 8

Create /usr/lib/jvm

sudo mkdir /usr/lib/jvm

Go to /usr/lib/jvm

cd /usr/lib/jvm

Extract JDK

sudo tar -xvzf ~/Downloads/jdk-8u221-linux-x64.tar.gz

Update java locations in Ubuntu

sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.8.0_221/bin/java" 0
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.8.0_221/bin/javac" 0
sudo update-alternatives --set java /usr/lib/jvm/jdk1.8.0_221/bin/java
sudo update-alternatives --set javac /usr/lib/jvm/jdk1.8.0_221/bin/javac

Check updated locations

update-alternatives --list java
update-alternatives --list javac

Check java version

java -version

Edit .bashrc

export ANDROID_SDK_ROOT=~/Downloads/sdk-tools-linux/
export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_221/
export PATH=${PATH}:${ANDROID_HOME}/platform-tools:${ANDROID_HOME}/tools:${ANDROID_HOME}/tools/bin
export GRADLE_HOME=/opt/gradle/gradle-5.0
export PATH=${GRADLE_HOME}/bin:${PATH}

Load new .bashrc

source ~/.bashrc

Accept all Android SDK licences

yes | sdkmanager --licenses

Install the required dependencies for cordova android

sdkmanager --install tools
sdkmanager --install platform-tools
sdkmanager --install "build-tools;26.0.0"
sdkmanager --install "platforms;android-26" 

Install gradle

wget https://services.gradle.org/distributions/gradle-5.0-bin.zip -P /tmp
sudo unzip -d /opt/gradle /tmp/gradle-*.zip

Run cordova android

Now the command

cordova run android

in your project will be done without any problems.

Word count: 296

Want to know more and be immediately informed about new posts?

Let's stay in touch and leave your email:

Related posts: