Gradle permission denied in Circle 2.0 Exited with code 126

I am new to circle ci.
I follow the below link

version: 2
    working_directory: ~/code
      - image: circleci/android:api-25-alpha
      JVM_OPTS: -Xmx3200m
      - checkout
      - 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:
            - ~/.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
      # See for deploy examples

i created the config.yml file directly from git website. and made a commit.

got an error like

#!/bin/bash -eo pipefaa il ./gradlew androidDependencies

/bin/bash: ./gradlew: Permission denied Exited with code 126

seen the same error for lot of people. but i didn’t get what exactly should do to solve this

command: |
            sudo chmod +x gradlew
            ./gradlew androidDependencies 

how to do the above thing to solve. should i change the file or. ?

  - run:
      name: Download Dependencies
      command: |
        sudo chmod +x ./gradlew
        ./gradlew androidDependencies 

Could you try this?

  `command: ./gradlew androidDependencies`

change to
command: sudo chmod +x ./gradlew

issue fixed

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.