I’ve been a long time only Ubuntu user and just recently formatted my desktop computer and bought a Windows 11. Point being, I made a tutorial on how to configure android sdk on windows too.

Instead of using Android studio, I’ll show you how you can install android sdk from the terminal.

Install Java

This is the first requirement, I prefer the Oracle version, but feel free to use openjdk if you like.

Verify the installation with java -version:

java version "17.0.10" 2024-01-16 LTS
Java(TM) SE Runtime Environment (build 17.0.10+11-LTS-240)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.10+11-LTS-240, mixed mode, sharing)

If you happen to get a different java version than the currently installed, you can always fix it by running:

sudo update-alternatives --config javac
sudo update-alternatives --config java

And I also suggest setting up the JAVA_HOME. Edit .profile and set:

export JAVA_HOME="/usr/lib/jvm/jdk-17-oracle-x64"

Save file, run source ~/.profile to update your current environment.

Get just the command line tools

These tools will help you do anything you need just from the command line, most importantly installing the sdk. Go to https://developer.android.com/studio and scroll down to command line tools, download.

command line tools, manual sdk install

Install the SDK

Extract your tools somewhere, and first run a small configuration as suggested by https://stackoverflow.com/a/71331807 to avoid the “could not determine SDK root” error.

unzip commandlinetools-linux-<your_version>.zip 
mv cmdline-tools ~/android-sdk/latest
cd ~/android-sdk/latest/cmdline-tools

Run this command from the cmd line tools to install version 34 of api and tools:

./sdkmanager "platform-tools" "platforms;android-34" "build-tools;34.0.0"

You can always see what’s available to install with sdkmanager --list.

Declare paths and environment variables

To be able to access platform-tools and cmdline-tools from anywhere, set up the env variables.

Edit .profile and add:

export ANDROID_HOME=$HOME/<location-of-sdk> # where did you extract the sdk?
export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin
export PATH=$PATH:$ANDROID_HOME/platform-tools
export PATH=$PATH:$ANDROID_HOME/emulator

Save file and run source .profile to propagate the changes.

Verify Installation

If everything went smoothly, `adb version` should give you something like:

Android Debug Bridge version 1.0.41
Version 34.0.1-9979309
Installed as /usr/bin/adb
Running on Linux 5-15-0-97-generic (x86_64)

Last Part

If you need an emulator, install system images and create an AVD (Android Virtual Device):

sdkmanager "system-images;android-34;default;x86_64"
avdmanager create avd -n testDevice -k "system-images;android-34;default;x86_64"

Check that your testDevice is in the list and run the emulator

emulator -list-avds
emulator @testDevice

Fun with Ubuntu

I said at the beginning of the article, things don’t go as smooth as they should.


Failed to install android-sdk: “java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema”

This SO provides a solution, I just wanted to add this kind of thing happens when sdk is downloaded via Android Studio and the included avdmanager is deprecated. You will not have this issue if you installed this manually.

Deprecated Java Version

has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0

This error only occurs if you have multiple java versions installed and have not configured the system properly. In my case it was java compiler pointing to the oracle java 8 version.

# this is correct
> java -version
openjdk version "11.0.21" 2023-10-17
OpenJDK Runtime Environment (build 11.0.21+9-post-Ubuntu-0ubuntu122.04)
OpenJDK 64-Bit Server VM (build 11.0.21+9-post-Ubuntu-0ubuntu122.04, mixed mode, sharing)
> javac -version
javac 1.8.0_171

You can fix it by running the command below and picking the newer version:

sudo update-alternatives --config javac
There are 2 choices for the alternative javac (providing /usr/bin/javac).

  Selection    Path                                          Priority   Status
* 0            /usr/lib/jvm/java-11-openjdk-amd64/bin/javac   1111      auto mode
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/javac   1111      manual mode
  2            /usr/lib/jvm/java-8-oracle/bin/javac           1081      manual mode


adb: failed to install .apk: Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package your.package signatures do not match previously installed version; ignoring!]

Error message is explanatory enough, solution is to uninstall your.package. This error might happen if you’re running expo android on your actual device, which had another version of your.package installed.

adb uninstall your.package


I’ve already covered setting up the SDK and troubleshooting common issues. This is just an extra section which applies to any OS platform: be it Linux, Windows or MacOS.

While you’re developing you’ll want to run your app on the emulator and real device, be able to communicate with other api services, debug…

Communicating with services

While you’re developing your app and testing either on your emulator or your device, you might need to access your local api. Localhost won’t do. Check that you’re on the same wifi, that your api is on or more restrictive 192.x.x.x (whatever ip is written in your network settings).

Other solution would be to use a service like ngrok, but then your api is open to the world if they manage to guess your ngrok url.

Adb device permission issues

Check that you have enabled development mode and usb debugging. Connected device should use usb for data transfer.

  • Try a different usb port
  • The adb usb command restarts the adb server and forces it to listen for USB connections, which can also help in resetting the USB interface for ADB.

Debugging Logs

Very useful when you’re running your app on an emulator or the device, expo logs will not be enough at times. Their errors are sometimes too cryptic. You can use adb logcat -e your.package to see what’s actually going on.

Running the emulator from virtualbox

While I was recording my youtube video, I was running Ubuntu from Virtualbox. I tried running the emulator from virtualbox, but error kept saying “missing hardware acceleration”.

You can run the emulator, just add “–no-accel”. No reason why you would want that because it’s extremely slow, but just pointing it’s doable.

Categories: Uncategorized


Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *