Android build fails - "dx.jar is missing"

I am attempting to build QGroundControl for Android following this guide. But I am getting increasingly confused.
Everything is running perfectly when building to my desktop - but as I change kits to build to Android issues arise.

The guide specifies Android NDK 19 and the build kit: Android for armeabi-v7a (GCC 4.9, Qt 5.12.6).
This seems impossible? From what I understand Android NDK stopped supporting GCC as of revision r18. So I’ve been using Clang instead.

My compile error looks as such;

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':preDexDebug'.
> java.lang.IllegalStateException: dx.jar is missing

My dx.jar file is found in {Android SDK dir}/build-tools/{version}/lib/
Cleaning or even deleting and reinstalling everything does not change anything.

I have tried with combinations of these different versions:

Ubuntu 20.04.2 LTS
Qt version 5.12.6

Android SDK Platform-Tools:
	31.0.3

Android SDK Build-Tools:
	29.0.2
	30.0.2
	31.0.0

Android SDK Platform:
	19
	30
	31

Android NDK:
	19.2.5345600
	21.3.6528147

Java JDK:
	jdk8u302-b08
	jdk-11.0.12+7

I am now running out of ideas.
Does anyone know how I could solve this?

I have the same problem

I am also having the same problem but for herelink repo - git@github.com:CubePilot/qgroundcontrol-herelink.git

It looks like the solution is to install the correct Android Studio build-tools version.

  1. Open Android Studio
  2. From the dropdown select More Actions->SDK Manager
  3. Select the SDK Tools Tab (under Android SDK Location)
  4. Select “Show Package Details” and uncheck “Hide Obsolete Packages”
  5. Under Android SDK Build-Tools 33-rc1 I selected 29.0.2 and Installed using the Apply button.
  6. You can double check in your SDK Folder and searching for ‘dx.jar’ which should appear now.

(note: I am building QGC 4.2 with qt 5.12.6)

1 Like