You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

CircleCI 2.0 Android项目构建报错:找不到androidDependencies

Fixing the "chmod: cannot access 'androidDependencies'" Error in CircleCI Android Build

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 03:33:06