Chmod: cannot access './gradlew': No such file or directory

Hi this is my config.yml for my Android project

Java Gradle CircleCI 2.0 configuration file

Check https://circleci.com/docs/2.0/language-java/ for more details

version: 2
jobs:
build:
docker:
# specify the version you desire here
- image: circleci/android:api-28-alpha

  # Specify service dependencies here if necessary
  # CircleCI maintains a library of pre-built images
  # documented at https://circleci.com/docs/2.0/circleci-images/
  # - image: circleci/postgres:9.4

working_directory: ~/code

environment:
  # Customize the JVM maximum heap limit
  JVM_OPTS: -Xmx3200m
  TERM: dumb

steps:
  - checkout

  # Download and cache dependencies
  - restore_cache:
      key: jars-{{ checksum "build.gradle" }}-{{ checksum  "app/build.gradle" }}

  - run:
      name: Chmod permissions #if permission for Gradlew Dependencies fail, use this.
      command: sudo chmod +x ./gradlew
  - run:
      name: Download Dependencies
      command: ./gradlew androidDependencies

  - save_cache:
      paths:
        - ~/.gradle
      key: v1-dependencies-{{ checksum "build.gradle" }}

and for this script i’am getting
chmod: cannot access ‘./gradlew’: No such file or directory
can anyone please help me

Hello

I am following up on old tickets in case people are running into the same issue.

The reason for this issue is due to the line: working_directory: ~/code

By default on CircleCI, you are in the ~/ folder but when you run the special checkout step using: - checkout it will do a git clone into a directory called project.

Because of this when you run ./gradlew it will fail as the gradlew file will be located under ~/project

The resolution for this is to either set ./gradlew to ~/project/gradlew or set working_directory: ~/project. If you are changing to the full path please be aware this may need to be changed for other files such as .gradle from the example given above.

Kind Regards
Owen Oliver