Lucas Batista
Lucas Batista

Reputation: 177

How specify an Android SDK Build Tools version on Azure DevOps Pipelines

I'm having a serious problem trying to create an Android CI/CD in Azure DevOps. Turns out the pipeline tries to use the latest version of BuildTools to build the apk, but the latest version (31.0.0) seems to be having problems.

I would like to force Azure to use version 30.0.3 that I have already tested is working perfectly.

Azure Log Using BuildTools 31.0.0

Azure Log 31

Local log using BuildTools 31.0.0

Local Log 31

Local log using BuildTools 30.0.0

Local Log 30

I'm using Ionic with cordova to generate my Android project, although cordova docs says it supports cli arguments to force build tools version.

eg.: ionic cordova run android -- --gradleArg=-P cdvBuildToolsVersion=30

It still generates in a way that will always use the most current version installed in the cordovaLib module

build.gradle [app module]

// The value for android.buildToolsVersion.
    if (!project.hasProperty('cdvBuildToolsVersion')) {
        cdvBuildToolsVersion = null;
    }

...

compileSdkVersion cdvCompileSdkVersion
buildToolsVersion cdvBuildToolsVersion

build.gradle [cordovaLib module]

cdvCompileSdkVersion = privateHelpers.getProjectTarget()
cdvBuildToolsVersion = privateHelpers.findLatestInstalledBuildTools()

...

compileSdkVersion cdvCompileSdkVersion
buildToolsVersion cdvBuildToolsVersion

Upvotes: 1

Views: 3486

Answers (1)

Lucas Batista
Lucas Batista

Reputation: 177

I found a temporary workaround that seems to make sense for this type of case and if someone has this type of problem in the future, it might be useful:

Just put a step in the pipeline to remove the corrupted build-tools, in this case, 31.0.0

- script: $ANDROID_HOME/tools/bin/sdkmanager --uninstall 'build-tools;31.0.0'
  displayName: 'Workaround'

Upvotes: 3

Related Questions