CircleCI 2.0 Android项目构建报错:找不到androidDependencies
Hey there! Let's break down what's causing this error and fix it up quickly.
The Root Cause
Looking at your circle.yml file, the problem lies in the Download Dependencies step. You combined two commands into one line without proper separation:
command: sudo chmod +x gradlew ./gradlew androidDependencies
When the shell runs this, it treats the entire string as a single chmod command—meaning it's trying to add execute permissions to a non-existent file named ./gradlew androidDependencies. That's why you're getting the "No such file or directory" error. The issue isn't with the androidDependencies task itself, it's how you're structuring the commands.
The Fix
First, you don't need sudo here—your CircleCI user already has permission to modify files in your project directory. Then, separate the two commands properly using either a semicolon or multi-line formatting.
Here's the corrected version of that step using multi-line commands (easier to read):
- run: name: Download Dependencies command: | chmod +x gradlew ./gradlew androidDependencies
If you prefer a single-line approach:
- run: name: Download Dependencies command: chmod +x gradlew; ./gradlew androidDependencies
Why This Works
chmod +x gradlew: Fixes your initial permission denied issue by granting execute access to the Gradle wrapper script../gradlew androidDependencies: Runs the valid Gradle task that downloads all your project's dependencies. You don't need to replace this task—it's exactly what you need here!
Full Corrected circle.yml
For clarity, here's your entire config with the fixed step included:
version: 2 jobs: build: working_directory: ~/code docker: - image: circleci/android:api-25-alpha environment: JVM_OPTS: -Xmx3200m steps: - checkout - restore_cache: key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }} - run: name: Download Dependencies command: | chmod +x gradlew ./gradlew androidDependencies - save_cache: paths: - ~/.gradle key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }} - run: name: Run Tests command: ./gradlew lint test - store_artifacts: path: app/build/reports destination: reports - store_test_results: path: app/build/test-results
Give this a run, and your build should sail past the dependency download step smoothly!
内容的提问来源于stack exchange,提问作者kevinivan05

