Permission Denied Error while building Android project

Hello,

Getting this error

#!/bin/bash -eo pipefail
./gradlew androidDependencies
/bin/bash: ./gradlew: Permission denied
Exited with code 126

Please provide the inputs to resolve it.

Thanks

If you are getting permission denied could you try to prefix your commands with sudo?

It would also help if you showed us your entire config and any scripts that are being called.

This is my config.yml code. As per your suggesstion I have also added sudo for command and after that I am getting error below

#!/bin/bash -eo pipefail
sudo ./gradlew androidDependencies
sudo: ./gradlew: command not found
Exited with code 1

config.yml
version: 2
jobs:
build:
working_directory: ~/code
docker:
- image: circleci/android:api-26-node8-alpha
environment:
JVM_OPTS: -Xmx3200m
steps:
- checkout
- restore_cache:
key: jars-{{ checksum “build.gradle” }}-{{ checksum “app/build.gradle” }}
- run:
name: Download Dependencies
command: sudo ./gradlew androidDependencies
- save_cache:
paths:
- ~/.gradle
key: jars-{{ checksum “build.gradle” }}-{{ checksum “app/build.gradle” }}
- run:
name: Run Tests
command: sudo ./gradlew lint test
- store_artifacts:
path: app/build/reports
destination: reports
- store_test_results:
path: app/build/test-results

Ah, I think the issue is actually that your ./gradlew is not executable. Can you run chmod +x gradlew and then try to run the command without sudo?

It looks like the exact same issue as here: Gradle permission denied in Circle 2.0 Give that a try and let us know if this works for you.