mainDexClasses command not found

In this troubleshooting guide we learn how to fix mainDexClasses command not found error message

Introduction

When you run more command in linux terminal / console, you get the following error message

mainDexClasses: command not found

or when using sudo you get the following error message

sudo: mainDexClasses: command not found

Solutions to mainDexClasses: command not found

How To Fix mainDexClasses: command not found in Ubuntu / Debian / Kali Linux / Raspbian

In Ubuntu mainDexClasses is provided by dalvik-exchange package.

dalvik-exchange is:

Dalvik is a process virtual machine in Google’s Android operating system that executes applications written for Android.

dalvik-exchange is the tool that takes in class files and reformulates them for consumption in the VM. It also does a few other things.

This program is officially named “dx” but in order to avoid naming conflict with OpenDX in Debian it is renamed to “dalvik-exchange”.

This package also provides the “mainDexClasses” program.

To fix this problem, we can install more using the command below.

sudo apt-get -y install dalvik-exchange

This command might take some time to finish depending on your machine internet connection.

You can also use apt command to install dalvik-exchange.

sudo apt -y install dalvik-exchange

Or if you have aptitude installed you can use the following command.

sudo aptitude install dalvik-exchange

Summary

In this tutorial we learn how to fix mainDexClasses command not found error in Ubuntu / Debian / Kali Linux or Raspbian distribution.