Installing android studio is a pain in the Ass, and installing it dependencies is a level up to that. The most complex among those is the JDK one.

Below are the steps to achieve so.

# install (open) jdk 8

sudo apt-get install -y openjdk-8-jdk

# update java compiler and set to 1.8

sudo update-alternatives --config javac

# update java runtime (optional)

sudo update-alternatives --config java

# Also set $JAVA_HOME and $PATH to your .bashrc (optional)

echo 'export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64' >> ~/.bashrc
echo 'export PATH="$PATH:$JAVA_HOME/bin' >> ~/.bashrc

# load in current bash session

source ~/.bashrc