Execution failed for task ‘:app:androidDependencies’ on Circle CI but not locally

人盡茶涼 提交于 2021-02-08 10:24:20

问题


Note that I posted this question on Circle CI's discussion forum too, so I'd like some feedback relating to my Gradle environment (i.e. downloading dependencies from Maven based on build type/variant), or heck, if you can help me out altogether on this issue as a whole!

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 - note errors towards the bottom of this post -, 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 config.yml file:

version: 2
jobs:
  build:
    working_directory: ~/code
    docker:
      - image: circleci/android:api-28
    environment:
      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"
    steps:
      - 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:
          paths:
            - ~/.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
debug

> 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:
         https://sdk.squareup.com/android/com/squareup/sdk/reader/reader-sdk-sq0idp-T4SClu2rWV2AcYcEiHALXg/1.3.6/reader-sdk-sq0idp-T4SClu2rWV2AcYcEiHALXg-1.3.6.jar
* 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

BUILD FAILED in 3m 4s
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
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip

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 - and please let me know if something looks wrong):

...

final SQUARE_READER_SDK_APP_ID_DEV = 'sq0idp-T4SClu2rWV2AcYcEiHALXg'
final SQUARE_READER_SDK_APP_ID_PROD = 'sq0idp-cyEZl-H328bxzEh0E4tq5w'
final SQUARE_READER_SDK_VERSION = "1.3.6"

...

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"

    ...
}

...

来源:https://stackoverflow.com/questions/61240438/execution-failed-for-task-appandroiddependencies-on-circle-ci-but-not-locall

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!