6

I recently faced an issue with my Azure CI pipeline when I tried to build apk for Android.

I get the below error:

Build-tool 31.0.0 is missing DX at /usr/local/lib/android/sdk/build-tools/31.0.0/dx

FAILURE: Build failed with an exception.

  • What went wrong: Could not determine the dependencies of task ':app:compileReleaseJavaWithJavac'.

Installed Build Tools revision 31.0.0 is corrupted. Remove and install again using the SDK Manager.

Work Around: I found a workaround for me when I changed my "cordova-android" version to "8.1.0" from "9.0.0" in package.json file or you can use "ionic cordova add andorid@8.1.0" instead of "ionic cordova add andorid".

Hope it helps.

James Z
  • 12,209
  • 10
  • 24
  • 44
el07
  • 65
  • 1
  • 5

1 Answers1

15

This is happened because dx files are missing from Android SDK Build Tools 31.0.0 and replaced with d8 files. Try to modify Android SDK Build Tools 31.0.0 by:

  1. In the Android SDK Build Tools 31.0.0 folder (example: C:\Users\Me\AppData\Local\Android\Sdk\build-tools\31.0.0), create a copy of d8.bat and rename it to dx.bat.
  2. In the lib folder, create a copy of d8.jar and rename it to dx.jar.
diazwijaya
  • 346
  • 3
  • 6
  • 1
    Yes this is a good solution if you are making builds on local machine. The one I proposed helps when you are building on DevOps pipeline. – el07 Aug 20 '21 at 09:03
  • This was the fix for me. I'm not sure I understand the DevOps pipeline solution, but being able to do a local build is certainly step one in any good dev process. – iGanja Aug 23 '21 at 19:44
  • 1
    Ah, pardon me @el07 You are right. Perhaps because `cordova-android 9.0.0` drop Travis CI, it'll always search latest Android Build Tools. Meanwhile `cordova-android 8.1.0` still using Travis CI and by default it'll use Android Build Tools 28.0.3. – diazwijaya Aug 25 '21 at 03:24
  • But where is the Android SDK Build Tools 31.0.0 folder? Remember that Cordova is for web devs who don't know anything about Android, iOS, etc. – Steve Dec 10 '21 at 02:54
  • It depends on your settings @Distortum. If you know your Android SDK location, just find folder build-tools/31.0.0. If you don't know the location, check it in Android Studio or environment settings. – diazwijaya Dec 10 '21 at 10:38
  • Another work-around is to downgrade to Android SDK Build Tools 30.0.3 – SuprMan Apr 25 '23 at 22:44