Azure DevOps gradle build fails

Issue

I am trying to migrate my pipeline from Appcenter to DevOps since I need to leverage some of the build-runtime tools.

The Appcenter builds are working fine, and I can run the app in the phone. But when I create a new pipeline in DevOps with a gradle task, the build fails with this following error:

2021-10-29T12:51:50.0106426Z ##[debug]Evaluating condition for step: 'gradlew buildDevRelease'
2021-10-29T12:51:50.0108994Z ##[debug]Evaluating: succeeded()
2021-10-29T12:51:50.0109520Z ##[debug]Evaluating succeeded:
2021-10-29T12:51:50.0110716Z ##[debug]> True
2021-10-29T12:51:50.0111404Z ##[debug]Result: True
2021-10-29T12:51:50.0112065Z ##[section]Starting: gradlew buildDevRelease
2021-10-29T12:51:50.0290629Z 
2021-10-29T12:51:50.0290945Z Task         : Gradle
2021-10-29T12:51:50.0291249Z Description  : Build using a Gradle wrapper script
2021-10-29T12:51:50.0291479Z Version      : 3.192.0
2021-10-29T12:51:50.0291852Z Author       : Microsoft Corporation
2021-10-29T12:51:50.0292241Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/gradle
2021-10-29T12:51:50.0293883Z 
2021-10-29T12:51:50.0622299Z ##[debug]Using node path: C:\agents\2.194.0\externals\node10\bin\node.exe
2021-10-29T12:51:50.2750480Z ##[debug]agent.TempDirectoryD:\a\_temp
2021-10-29T12:51:50.2801457Z ##[debug]loading inputs and endpoints
2021-10-29T12:51:50.2851215Z ##[debug]loading ENDPOINT_AUTH_PARAMETER_SYSTEMVSSCONNECTION_ACCESSTOKEN
2021-10-29T12:51:50.2872890Z ##[debug]loading ENDPOINT_AUTH_SCHEME_SYSTEMVSSCONNECTION
2021-10-29T12:51:50.2876666Z ##[debug]loading ENDPOINT_AUTH_SYSTEMVSSCONNECTION
2021-10-29T12:51:50.2880252Z ##[debug]loading INPUT_CHECKSTYLEANALYSISENABLED
2021-10-29T12:51:50.2882712Z ##[debug]loading INPUT_CLASSFILESDIRECTORIES
2021-10-29T12:51:50.2887154Z ##[debug]loading INPUT_CODECOVERAGETOOL
2021-10-29T12:51:50.2890379Z ##[debug]loading INPUT_CWD
2021-10-29T12:51:50.2893246Z ##[debug]loading INPUT_FAILIFCOVERAGEEMPTY
2021-10-29T12:51:50.2895945Z ##[debug]loading INPUT_FINDBUGSANALYSISENABLED
2021-10-29T12:51:50.2898790Z ##[debug]loading INPUT_GRADLE5XORHIGHER
2021-10-29T12:51:50.2902304Z ##[debug]loading INPUT_GRADLEOPTS
2021-10-29T12:51:50.2904722Z ##[debug]loading INPUT_JAVAHOMESELECTION
2021-10-29T12:51:50.2907326Z ##[debug]loading INPUT_JDKARCHITECTURE
2021-10-29T12:51:50.2910032Z ##[debug]loading INPUT_JDKVERSION
2021-10-29T12:51:50.2912958Z ##[debug]loading INPUT_PMDANALYSISENABLED
2021-10-29T12:51:50.2915909Z ##[debug]loading INPUT_PUBLISHJUNITRESULTS
2021-10-29T12:51:50.2920192Z ##[debug]loading INPUT_SPOTBUGSANALYSISENABLED
2021-10-29T12:51:50.2924388Z ##[debug]loading INPUT_SPOTBUGSGRADLEPLUGINVERSION
2021-10-29T12:51:50.2926773Z ##[debug]loading INPUT_SPOTBUGSGRADLEPLUGINVERSIONCHOICE
2021-10-29T12:51:50.2929294Z ##[debug]loading INPUT_SQANALYSISENABLED
2021-10-29T12:51:50.2932408Z ##[debug]loading INPUT_SQGRADLEPLUGINVERSION
2021-10-29T12:51:50.2934838Z ##[debug]loading INPUT_SQGRADLEPLUGINVERSIONCHOICE
2021-10-29T12:51:50.2937137Z ##[debug]loading INPUT_TASKS
2021-10-29T12:51:50.2939513Z ##[debug]loading INPUT_TESTRESULTSFILES
2021-10-29T12:51:50.2942260Z ##[debug]loading INPUT_WRAPPERSCRIPT
2021-10-29T12:51:50.2951095Z ##[debug]loaded 25
2021-10-29T12:51:50.2958461Z ##[debug]Agent.ProxyUrlundefined
2021-10-29T12:51:50.2962930Z ##[debug]Agent.CAInfoundefined
2021-10-29T12:51:50.2964523Z ##[debug]Agent.ClientCertundefined
2021-10-29T12:51:50.2965351Z ##[debug]Agent.SkipCertValidationundefined
2021-10-29T12:51:50.5189693Z ##[debug]check path : D:\a\_tasks\Gradle_xxx\3.192.0\node_modules\azure-pipelines-tasks-codecoverage-tools\module.json
2021-10-29T12:51:50.5194028Z ##[debug]adding resource file: D:\a\_tasks\Gradle_xxx\3.192.0\node_modules\azure-pipelines-tasks-codecoverage-tools\module.json
2021-10-29T12:51:50.5194943Z ##[debug]system.cultureen-US
2021-10-29T12:51:50.5256305Z ##[debug]Resource file has already set to: D:\a\_tasks\Gradle_xxx\3.192.0\node_modules\azure-pipelines-tasks-codecoverage-tools\module.json
2021-10-29T12:51:50.5266838Z ##[debug]Resource file has already set to: D:\a\_tasks\Gradle_xxx\3.192.0\node_modules\azure-pipelines-tasks-codecoverage-tools\module.json
2021-10-29T12:51:50.5278218Z ##[debug]Resource file has already set to: D:\a\_tasks\Gradle_xxx\3.192.0\node_modules\azure-pipelines-tasks-codecoverage-tools\module.json
2021-10-29T12:51:50.5299561Z ##[debug]Resource file has already set to: D:\a\_tasks\Gradle_xxx\3.192.0\node_modules\azure-pipelines-tasks-codecoverage-tools\module.json
2021-10-29T12:51:50.5309613Z ##[debug]Resource file has already set to: D:\a\_tasks\Gradle_xxx\3.192.0\node_modules\azure-pipelines-tasks-codecoverage-tools\module.json
2021-10-29T12:51:50.5750887Z ##[debug]check path : D:\a\_tasks\Gradle_xxx\3.192.0\node_modules\azure-pipelines-tasks-java-common\lib.json
2021-10-29T12:51:50.5752213Z ##[debug]adding resource file: D:\a\_tasks\Gradle_xxx\3.192.0\node_modules\azure-pipelines-tasks-java-common\lib.json
2021-10-29T12:51:50.5753060Z ##[debug]system.cultureen-US
2021-10-29T12:51:50.5772282Z ##[debug]check path : D:\a\_tasks\Gradle_xxx\3.192.0\task.json
2021-10-29T12:51:50.5773261Z ##[debug]adding resource file: D:\a\_tasks\Gradle_xxx\3.192.0\task.json
2021-10-29T12:51:50.5774924Z ##[debug]system.cultureen-US
2021-10-29T12:51:50.5802660Z ##[debug]wrapperScriptD:\a\1\s\gradlew
2021-10-29T12:51:50.5806205Z ##[debug]check path : D:\a\1\s\gradlew
2021-10-29T12:51:50.5809991Z ##[debug]Append .bat extension name to gradlew script.
2021-10-29T12:51:50.5817085Z ##[debug]cwdD:\a\1\s
2021-10-29T12:51:50.5818084Z ##[debug]check path : D:\a\1\s
2021-10-29T12:51:50.5882407Z ##[debug]javaHomeSelectionJDKVersion
2021-10-29T12:51:50.5884176Z ##[debug]codeCoverageToolNone
2021-10-29T12:51:50.5886431Z ##[debug]failIfCoverageEmptyfalse
2021-10-29T12:51:50.5888165Z ##[debug]publishJUnitResultsfalse
2021-10-29T12:51:50.5890062Z ##[debug]testResultsFilesD:\a\1\s\**\TEST-*.xml
2021-10-29T12:51:50.5893049Z ##[debug]tasksbuildDevRelease
2021-10-29T12:51:50.6002238Z ##[debug]System.DefaultWorkingDirectoryD:\a\1\s
2021-10-29T12:51:50.6003313Z ##[debug]gradle5xOrHighertrue
2021-10-29T12:51:50.6004181Z ##[debug]which 'D:\a\1\s\gradlew.bat'
2021-10-29T12:51:50.6004863Z ##[debug]found: 'D:\a\1\s\gradlew.bat'
2021-10-29T12:51:50.6005505Z ##[debug]optionsundefined
2021-10-29T12:51:50.6006280Z ##[debug]D:\a\1\s\gradlew.bat arg: ["buildDevRelease"]
2021-10-29T12:51:50.6007001Z ##[debug]Using JDK version to find and set JAVA_HOME
2021-10-29T12:51:50.6007655Z ##[debug]jdkVersiondefault
2021-10-29T12:51:50.6008935Z ##[debug]jdkArchitecturex64
2021-10-29T12:51:50.6009627Z ##[debug]Agent.Version2.194.0
2021-10-29T12:51:50.6420443Z ##[debug]Processed: ##vso[telemetry.publish areaTaskHub;featureGradle]{"jdkVersion":"default"}
2021-10-29T12:51:50.6422301Z ##[debug]gradleOpts-Xmx1024m
2021-10-29T12:51:50.6422957Z ##[debug]GRADLE_OPTS is now set to -Xmx1024m
2021-10-29T12:51:50.6423518Z ##[debug]Enabled code coverage successfully
2021-10-29T12:51:50.6424049Z ##[debug]sqAnalysisEnabledfalse
2021-10-29T12:51:50.6424671Z ##[debug]System.DefaultWorkingDirectoryD:\a\1\s
2021-10-29T12:51:50.6425267Z ##[debug]build.artifactStagingDirectoryD:\a\1\a
2021-10-29T12:51:50.6425826Z ##[debug]build.buildNumber508413
2021-10-29T12:51:50.6426362Z ##[debug]checkstyleAnalysisEnabledfalse
2021-10-29T12:51:50.6426892Z ##[debug]findbugsAnalysisEnabledfalse
2021-10-29T12:51:50.6427407Z ##[debug]pmdAnalysisEnabledfalse
2021-10-29T12:51:50.6427923Z ##[debug]spotBugsAnalysisEnabledfalse
2021-10-29T12:51:50.6428439Z ##[debug]Getting credentials for account feeds
2021-10-29T12:51:50.6428980Z ##[debug]SYSTEMVSSCONNECTION exists true
2021-10-29T12:51:50.6429489Z ##[debug]Got auth token
2021-10-29T12:51:50.6430002Z ##[debug]exec tool: D:\a\1\s\gradlew.bat
2021-10-29T12:51:50.6430516Z ##[debug]arguments:
2021-10-29T12:51:50.6432171Z ##[debug]   buildDevRelease
2021-10-29T12:51:50.6432698Z [command]C:\Windows\system32\cmd.exe /D /S /C "D:\a\1\s\gradlew.bat buildDevRelease"
2021-10-29T12:51:53.7159768Z Downloading https://services.gradle.org/distributions/gradle-6.7.1-bin.zip
2021-10-29T12:51:59.5887237Z ..................................................................................................
2021-10-29T12:51:59.5888721Z Unzipping C:\Users\VssAdministrator\.gradle\wrapper\dists\gradle-6.7.1-bin\xxxx\gradle-6.7.1-bin.zip to C:\Users\VssAdministrator\.gradle\wrapper\dists\gradle-6.7.1-bin\xxxx
2021-10-29T12:52:02.0653604Z 
2021-10-29T12:52:02.0655902Z Welcome to Gradle 6.7.1!
2021-10-29T12:52:02.0656442Z 
2021-10-29T12:52:02.0658069Z Here are the highlights of this release:
2021-10-29T12:52:02.0659792Z  - File system watching is ready for production use
2021-10-29T12:52:02.0692455Z  - Declare the version of Java your build requires
2021-10-29T12:52:02.0693064Z  - Java 15 support
2021-10-29T12:52:02.0693208Z 
2021-10-29T12:52:02.0693687Z For more details see https://docs.gradle.org/6.7.1/release-notes.html
2021-10-29T12:52:02.0694043Z 
2021-10-29T12:52:02.4479601Z Starting a Gradle Daemon (subsequent builds will be faster)
2021-10-29T12:52:41.2507309Z WARNING:: Using flatDirs should be avoided because it doesn't support any meta-data formats.
2021-10-29T12:52:41.2533674Z Currently detected usages:
2021-10-29T12:52:41.2534770Z - repository flatDir used in: project ':app'
2021-10-29T12:52:41.2535702Z WARNING:: Please remove usages of `jcenter()` Maven repository from your build scripts and migrate your build to other Maven repositories.
2021-10-29T12:52:41.2536632Z This repository is deprecated and it will be shut down in the future.
2021-10-29T12:52:41.2537563Z See http://developer.android.com/r/tools/jcenter-end-of-service for more information.
2021-10-29T12:52:41.2538392Z Currently detected usages in: root project 'yyy', project ':app'
2021-10-29T12:52:41.2539963Z 
2021-10-29T12:52:41.2540597Z FAILURE: Build failed with an exception.
2021-10-29T12:52:41.2541093Z 
2021-10-29T12:52:41.2541648Z * What went wrong:
2021-10-29T12:52:41.2542318Z Task 'buildDevRelease' not found in root project 'yyy'.
2021-10-29T12:52:41.2542846Z 
2021-10-29T12:52:41.2543555Z * Try:
2021-10-29T12:52:41.2544373Z Run gradlew tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
2021-10-29T12:52:41.2547588Z 
2021-10-29T12:52:41.2548278Z * Get more help at https://help.gradle.org
2021-10-29T12:52:41.2548766Z 
2021-10-29T12:52:41.2549388Z BUILD FAILED in 48s
2021-10-29T12:52:42.1249673Z Error: The process 'D:\a\1\s\gradlew.bat' failed with exit code 1
2021-10-29T12:52:42.1250803Z ##[debug]Exit code 1 received from tool 'D:\a\1\s\gradlew.bat'
2021-10-29T12:52:42.1251893Z     at ExecState._setResult (D:\a\_tasks\Gradle_xxx\3.192.0\node_modules\azure-pipelines-task-lib\toolrunner.js:944:25)
2021-10-29T12:52:42.1252733Z ##[debug]STDIO streams have closed for tool 'D:\a\1\s\gradlew.bat'
2021-10-29T12:52:42.1265472Z     at ExecState.CheckComplete (D:\a\_tasks\Gradle_xxx\3.192.0\node_modules\azure-pipelines-task-lib\toolrunner.js:927:18)
2021-10-29T12:52:42.1266307Z ##[debug]taskRunner fail
2021-10-29T12:52:42.1269822Z     at ChildProcess.<anonymous> (D:\a\_tasks\Gradle_xxx\3.192.0\node_modules\azure-pipelines-task-lib\toolrunner.js:840:19)
2021-10-29T12:52:42.1271101Z ##[debug]Processing code analysis results
2021-10-29T12:52:42.1297780Z     at ChildProcess.emit (events.js:198:13)
2021-10-29T12:52:42.1298423Z ##[debug]System.DefaultWorkingDirectoryD:\a\1\s
2021-10-29T12:52:42.1300645Z     at maybeClose (internal/child_process.js:982:16)
2021-10-29T12:52:42.1301323Z ##[debug]build.artifactStagingDirectoryD:\a\1\a
2021-10-29T12:52:42.1302572Z     at Socket.stream.socket.on (internal/child_process.js:389:11)
2021-10-29T12:52:42.1303325Z ##[debug]build.buildNumber508413
2021-10-29T12:52:42.1304176Z     at Socket.emit (events.js:198:13)
2021-10-29T12:52:42.1304681Z ##[debug][CA] Attempting to find report files from 4 code analysis tool(s)
2021-10-29T12:52:42.1305521Z     at Pipe._handle.close (net.js:607:12)
2021-10-29T12:52:42.1306006Z ##[debug]checkstyleAnalysisEnabledfalse
2021-10-29T12:52:42.1307388Z ##[debug][CA] Checkstyle analysis is not enabled.
2021-10-29T12:52:42.1308255Z ##[debug]findbugsAnalysisEnabledfalse
2021-10-29T12:52:42.1309045Z ##[debug][CA] FindBugs analysis is not enabled.
2021-10-29T12:52:42.1309732Z ##[debug]pmdAnalysisEnabledfalse
2021-10-29T12:52:42.1310406Z ##[debug][CA] PMD analysis is not enabled.
2021-10-29T12:52:42.1311081Z ##[debug]spotBugsAnalysisEnabledfalse
2021-10-29T12:52:42.1312007Z ##[debug][CA] SpotBugs analysis is not enabled.
2021-10-29T12:52:42.1312852Z ##[debug][CA] Skipping artifact upload: No analysis results
2021-10-29T12:52:42.1322261Z ##[debug]task result: Failed
2021-10-29T12:52:42.1364578Z ##[error]Error: The process 'D:\a\1\s\gradlew.bat' failed with exit code 1
2021-10-29T12:52:42.1376805Z ##[debug]Processed: ##vso[task.issue typeerror;]Error: The process 'D:\a\1\s\gradlew.bat' failed with exit code 1
2021-10-29T12:52:42.1389933Z ##[debug]Processed: ##vso[task.complete resultFailed;]Error: The process 'D:\a\1\s\gradlew.bat' failed with exit code 1
2021-10-29T12:52:42.1395014Z ##[section]Finishing: gradlew buildDevRelease

Here is the gradle.build file:

plugins {
    id 'com.android.application'
}

Properties properties  new Properties()
if (rootProject.file("apikey.properties").exists()) {
    properties.load(rootProject.file("apikey.properties").newDataInputStream())
}
def scope  properties.getProperty("SCOPE")
def client_Id  properties.getProperty("CLIENT_ID")
def client_Secret  properties.getProperty("CLIENT_SECRET")
def grant_Type  properties.getProperty("GRANT_TYPE")


android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"


    defaultConfig {
        applicationId "com.yyy"
        minSdkVersion 21
        targetSdkVersion 30
        versionCode 2
        versionName "1.3"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

        // should correspond to key/value pairs inside the file
        buildConfigField("String", "SCOPE", "\"$scope\"")
        buildConfigField("String", "CLIENT_ID", "\"$client_Id\"")
        buildConfigField("String", "CLIENT_SECRET", "\"$client_Secret\"")
        buildConfigField("String", "GRANT_TYPE", "\"$grant_Type\"")

    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}
repositories {
    flatDir {
        dirs 'libs'
    }
}
dependencies {

    //implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.2.1'
    //implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
    //implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.fragment:fragment:1.2.5'
    implementation 'org.jetbrains:annotations:15.0'
    implementation 'org.jetbrains:annotations:15.0'
    implementation 'androidx.appcompat:appcompat:1.3.1'
    implementation 'androidx.preference:preference:1.1.1'
    implementation 'com.google.android.gms:play-services-gcm:17.0.0'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.ext:truth:1.4.0'
    androidTestImplementation 'com.google.truth:truth:1.0.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.4.0'
    androidTestImplementation 'androidx.test.espresso:espresso-intents:3.4.0'
    androidTestImplementation 'androidx.test.espresso:espresso-accessibility:3.4.0'
    androidTestImplementation 'androidx.test.espresso:espresso-web:3.4.0'
    androidTestImplementation 'androidx.test.espresso.idling:idling-concurrent:3.4.0'
    androidTestImplementation 'androidx.test:core:1.4.0'
    androidTestImplementation 'androidx.test:runner:1.4.0'
    androidTestImplementation 'androidx.test:rules:1.4.0'


    def room_version  "2.3.0"

    implementation "androidx.room:room-runtime:$room_version"
    annotationProcessor "androidx.room:room-compiler:$room_version"
    implementation "androidx.room:room-rxjava2:$room_version"
    implementation "androidx.room:room-rxjava3:$room_version"
    implementation "androidx.room:room-guava:$room_version"
    testImplementation "androidx.room:room-testing:$room_version"

    def appCenterSdkVersion  '4.1.0'
    implementation "com.microsoft.appcenter:appcenter-analytics:${appCenterSdkVersion}"
    implementation "com.microsoft.appcenter:appcenter-crashes:${appCenterSdkVersion}"

    //implementation files('../libs/CortexDecoderLibrary.aar')

    implementation(name:'CortexDecoderLibrary', ext:'aar')
    //implementation(name:'bluebird-barcode', ext:'jar')

    // Retrofit, Gson and logging interceptor
    implementation 'com.squareup.retrofit2:retrofit:2.3.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.9.0'

    def work_version  "2.4.0"

    // WorkerManager
    implementation "androidx.work:work-runtime:$work_version"

    implementation 'androidx.percentlayout:percentlayout:1.0.0'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.appcompat:appcompat:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

    //implementation "com.android.support:support-v4:23.0.1"
}

Any suggestion is very welcomed, I am stuck!

Solution

Found out that the error was I did not point to the correct build artifact. Pointed to some old artifact that was not correct. Had to check the location where pipeline was building and point to that directory instead.

Answered By – CompileNow

Leave a Comment