gradlew assemble failing on Travis-CI

If you don't want to add .jar file into your repository, you can install wrapper before your build is started on travi-ci:

install: gradle wrapper --gradle-version 4.2

language: java

jdk:
  - oraclejdk8

More about wrapper in gradle documentation and install commands in travis-ci doc.


For anyone passing by my issue was in my .gitignore file. I inadvertently added this entry:

gradle/

Which was causing gradle/wrapper/gradle-wrapper.jar to not be included in my repo. Removing this entry in the .gitignore file and committing the changes to the repo fixed the issue.


In fact, not only gradle/wrapper/gradle-wrapper.jar has to be there, but also it should have -x permission. So if you already committed it, but it doesnot have -x, you should do the following:

  1. chmod +x gradle/wrapper/gradle-wrapper.jar
  2. git add -f gradle/wrapper/gradle-wrapper.jar

Reference: Could not find or load main class org.gradle.wrapper.GradleWrapperMain