Gradle permission denied in Circle 2.0

android
gradle

#1

Hi! I’m using Circle CI 2.0 but right now I’m having this problem. I already did the initial configuration with this code:

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: ./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

The error is in the dependencies section:

export TERM="dumb"
if [ -e ./gradlew ]; then ./gradlew dependencies;else gradle dependencies;fi
bash: line 2: ./gradlew: Permission denied

export TERM="dumb"
if [ -e ./gradlew ]; then ./gradlew dependencies;else gradle dependencies;fi
returned exit code 126

Action failed: gradle dependencies

What can I do?


#2

You can add permission before push to your repo,

You can try in your local machine with:

sudo chmod +x ./gradlew

And then add on git, create a commit and push to your repo again


#3

Hello, I am new to Circle build, I am also getting same error. So where I need to put the

sudo

command.

Thanks


#4

What is the exact error you’re getting? What file does not have sufficient permissions? What config do you have - are you using CircleCI 1.0 or 2.0? May we see your configuration file, in a code-formatted block?


#5

Thanks for the help @rafaelje.

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

With sudo command my error got resolved.

Thanks
Mohammed


Permission Denied Error while building Android project
#6