Travis CI + Android build error: Permission denied

#1

I get this error when building my project (Android App) from Travis CI dashboard:

/home/travis/.travis/functions: line 104: ./gradlew: Permission denied

Here is my .travis.yml file:

language: android
sudo: required
jdk:
    - oraclejdk8
android:
  components:
    - tools # to get the new `repository-11.xml`
    - tools # see https://github.com/travis-ci/travis-ci/issues/6040#issuecomment-219367943)
    - platform-tools
    - build-tools-$ANDROID_BUILD_TOOLS
    - android-$ANDROID_API
    - android-$EMULATOR_API_LEVEL
before_install:
    - yes | sdkmanager "platforms;android-27"
    - mkdir "$ANDROID_HOME/licenses" || true
    - echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license"
    - echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "$ANDROID_HOME/licenses/android-sdk-preview-license"
    - chmod +x gradlew
    - ./gradlew dependencies || true
before_script:
    - echo no | android create avd --force -n test -t android-21 --abi armeabi-v7a
    - emulator -avd test -no-skin -no-audio -no-window &   
    - android-wait-for-emulator
    - adb shell input keyevent 82 &
script:
    - ./gradlew build connectedCheck
    - "./gradlew clean build connectedCheck -PdisablePreDex --stacktrace"
before_cache:
    -rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
    -rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
    directories:
        -$HOME/.gradle/caches/
        -$HOME/.gradle/wrapper/
 env:
    global:
        - ANDROID_API=28
        - EMULATOR_API=24
        - ANDROID_BUILD_TOOLS=28.0.3
        - ADB_INSTALL_TIMEOUT=5 # minutes
 licenses:
    - android-sdk-preview-license-.+
    - android-sdk-license-.+
    - google-gdk-license-.+

I’ve tried to fix this by adding both adding - chmod +x gradlew to my travis.yml file and and doing git update-index --chmod=+x gradlew. This set the gradlew variable to 100755 blob xxxxxxxxxxxxx gradlew but my build is still failing.

Any suggestions?