Search code examples
androidcordovaionic-frameworkazure-devops

Azure DevOps ionic Android Build Error "Build-tool 31.0.0 is missing DX at /usr/local/lib/android/sdk/build-tools/31.0.0/dx"


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 [email protected]" instead of "ionic cordova add andorid".

Hope it helps.


Solution

  • 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.