Execution failed for task ':app:androidDependencies' on Circle but not locally

For some reason, I can’t get the dependencies (Square’s Reader SDK in this case, and yes, I confirmed with the Square team that only aar files should be downloaded instead of jar from Maven, so it’s not on their end) to download on Circle, whereas getting the Gradle to build and running the ./gradlew androidDependencies task works fine locally on my machine using Android Studio. I confirmed the same results with my other coworkers.

At this point, Gradle may obviously be the problem here where we need to figure out how to get the Gradle via Circle in-sync with our local environments. And no, updating both the Android Gradle plugin and Gradle version incrementally didn’t work either (i.e. from 3.4.1 to 3.5.3 for the Android Gradle plugin version, and from 5.1.1 to 5.4.1 for the Gradle version): https://developer.android.com/studio/releases/gradle-plugin#updating-gradle. So we’re inclined to keep the versions as-is since everything is already working locally.

Here’s the relevant parts of the yml file:

version: 2
    working_directory: ~/code
      - image: circleci/android:api-28
      GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError -XX:ParallelGCThreads=2 -XX:ConcGCThreads=2 -XX:ParallelGCThreads=2 -Djava.util.concurrent.ForkJoinPool.common.parallelism=2"'
      _JAVA_OPTIONS: "-Xmx2048m -XX:ParallelGCThreads=2 -XX:ConcGCThreads=2 -XX:ParallelGCThreads=2 -Djava.util.concurrent.ForkJoinPool.common.parallelism=2"
      TZ: "/usr/share/zoneinfo/America/Indianapolis"
      - checkout
      - restore_cache:
          key: jars-{{ checksum "build.gradle" }}-{{ checksum  "app/build.gradle" }}
      - run:
          name: Download Dependencies
          command: ./gradlew androidDependencies -PsquareReaderSdkPasswordDev=$SQUARE_READER_SDK_REPO_PW_DEV -PsquareReaderSdkPasswordProd=$SQUARE_READER_SDK_REPO_PW_PROD -PnexusUsername=$NEXUS_USER -PnexusPassword=$NEXUS_PW -PdisablePreDex=true -PdexJavaMaxHeapSize=512m -PdexMaxProcessCount=1 --no-daemon --max-workers=1
      - save_cache:
            - ~/.gradle
          key: jars-{{ checksum "build.gradle" }}-{{ checksum  "app/build.gradle" }}


Here’s the relevant Circle build logs for the “Download Dependencies” step below, and note that a jar file is trying to be retrieved even though aar is the only one available on Maven:

#!/bin/bash -eo pipefail ./gradlew androidDependencies -PsquareReaderSdkPasswordDev=$SQUARE_READER_SDK_REPO_PW_DEV -PsquareReaderSdkPasswordProd=$SQUARE_READER_SDK_REPO_PW_PROD -PnexusUsername=$NEXUS_USER -PnexusPassword=$NEXUS_PW -PdisablePreDex=true -PdexJavaMaxHeapSize=512m -PdexMaxProcessCount=1 --no-daemon --max-workers=1

Picked up _JAVA_OPTIONS: -Xmx2048m -XX:ParallelGCThreads=2 -XX:ConcGCThreads=2 -XX:ParallelGCThreads=2 -Djava.util.concurrent.ForkJoinPool.common.parallelism=2 
Downloading https://services.gradle.org/distributions/gradle-5.1.1-all.zip......
Unzipping /home/circleci/.gradle/wrapper/dists/gradle-5.1.1-all/4roc7ipeffh0uifn0m8u5ua5qc/gradle-5.1.1-all.zip to /home/circleci/.gradle/wrapper/dists/gradle-5.1.1-all/4roc7ipeffh0uifn0m8u5ua5qc
Set executable permissions for: /home/circleci/.gradle/wrapper/dists/gradle-5.1.1-all/4roc7ipeffh0uifn0m8u5ua5qc/gradle-5.1.1/bin/gradle

Welcome to Gradle 5.1.1!

Here are the highlights of this release:
 - Control which dependencies can be retrieved from which repositories
 - Production-ready configuration avoidance APIs

For more details see https://docs.gradle.org/5.1.1/release-notes.html

To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: https://docs.gradle.org/5.1.1/userguide/gradle_daemon.html.
Daemon will be stopped at the end of the build stopping after processing


> Task :app:androidDependencies

> Task :app:androidDependencies FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:androidDependencies'.
> Could not resolve all artifacts for configuration ':app:debugCompileClasspath'.
   > Could not find reader-sdk-sq0idp-T4SClu2rWV2AcYcEiHALXg.jar (com.squareup.sdk.reader:reader-sdk-sq0idp-T4SClu2rWV2AcYcEiHALXg:1.3.6).
     Searched in the following locations:
* Try:
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.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings

1 actionable task: 1 executed

Exited with code exit status 1

root level build.gradle file’s Android Gradle plugin version:

classpath 'com.android.tools.build:gradle:3.4.1'

… and the Gradle version from the gradle-wrapper.properties file:

#Tue Apr 14 15:24:05 EDT 2020

Here’s the relevant parts of the app level build.gradle file (and note the respective dependencies getting downloaded from Maven based on build type - debug/dev and prod in this case):


final SQUARE_READER_SDK_APP_ID_PROD = 'sq0idp-cyEZl-H328bxzEh0E4tq5w'


buildTypes {
    debug {

        repositories {
            maven {
                url "https://sdk.squareup.com/android"
                credentials {
                    username SQUARE_READER_SDK_APP_ID_DEV
                    // Set as a property from command
                    password squareReaderSdkPasswordDev

    release {

        repositories {
            maven {
                url "https://sdk.squareup.com/android"
                credentials {
                    username SQUARE_READER_SDK_APP_ID_PROD
                    // Set as a property from command
                    password squareReaderSdkPasswordProd


dependencies { 

    debugImplementation "com.squareup.sdk.reader:reader-sdk-$SQUARE_READER_SDK_APP_ID_DEV:$SQUARE_READER_SDK_VERSION"
    releaseImplementation "com.squareup.sdk.reader:reader-sdk-$SQUARE_READER_SDK_APP_ID_PROD:$SQUARE_READER_SDK_VERSION"
    runtimeOnly "com.squareup.sdk.reader:reader-sdk-internals:$SQUARE_READER_SDK_VERSION"