Android: could not find or load main class org.gradle.wrapper.GradleWrapperMain

I am trying to create my own project on GitLab CI, but unfortunately for me I always get this error inside the runner:

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

Now I know that something is wrong with my environment, but I just can not figure it out. I searched on the Internet and I found that I needed to update the .gitignore file, and I did this:

 ### Java ### *.class ### Android ### *.apk *.ap_ ### Package files ### *.war *.ear *.aar ### Gradle ### .gradle build bin/ build/ build.xml gen/ .gradle/ gradlew gradlew.bat gradle-wrapper.jar gradle-wrapper.properties ### Android Studio ### .idea local.properties .DS_Store /captures 

I also modified my gradle.build to contain the following lines:

 task wrapper(type: Wrapper) { gradleVersion = '2.0' } 

But again, every time I run the build, I get a stack! Here is also my .gitlab-ci.yml :

 before_script: - apt-get --quiet update --yes - apt-get --quiet install --yes wget tar unzip openjdk-7-jdk lib32stdc++6 lib32z1 - wget --quiet --output-document=gradle.zip https://services.gradle.org/distributions/gradle-2.8-bin.zip - unzip -q gradle.zip - export ANDROID_HOME="/opt/android-sdk" - chmod +x gradlew dev: script: - ./gradlew assembleDebug 

And the line where the error appears:

 - wget --quiet --output-document=gradle.zip https://services.gradle.org/distributions/gradle-2.8-bin.zip 
+6
source share
3 answers

According to your gitignor , CI never gets the gradle-wrapper.jar library because it has not been executed yet, but it should be because it is used to run the shell.

Check if gradle-wrapper.jar , if not then just execute it.

+5
source

I got this error while trying to run:

 ./gradlew releaseTarGz Could not find or load main class org.gradle.wrapper.GradleWrapperMain 

My mistake was that I did not read or follow the instructions: first I had to execute these two commands in order to initialize things:

 gradle ./gradlew jar 

Then ./gradlew releaseTarGz can find this main class as expected.

+2
source

@ Stanislav, you were partly right. I managed to find out the problem and, of course, as expected, it was right before my eyes. So, as we all know, the runner / s on GitLab CI is all โ€œemptyโ€. This means that nothing is installed on them. That is why we have .gitlab-ci.yml . Now, looking back at my .gitlab-ci.yml , I am telling the runner to get jdk7 and gradle , but I am missing the Android SDK , so I got an error:

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

So my new .gitlab-ci.yml looks like this and it compiles as it should:

 before_script: - apt-get --quiet update --yes - apt-get --quiet install --yes wget tar unzip openjdk-7-jdk lib32stdc++6 lib32z1 - wget --quiet --output-document=android-sdk.tgz https://dl.google.com/android/android-sdk_r24.4.1-linux.tgz - tar --extract --gzip --file=android-sdk.tgz - echo y | android-sdk-linux/tools/android --silent update sdk -a -u -t 1,2,3,4,5,6,29,31,32,33,34,45,138,142,145,146,147,148,149,150,151 - wget --quiet --output-document=gradle.zip https://services.gradle.org/distributions/gradle-2.12-bin.zip - unzip -q gradle.zip - export ANDROID_HOME=$PWD/android-sdk-linux build: script: - gradle-2.12/bin/gradle assembleDebug artifacts: paths: - app/build/outputs/apk/app-release-unsigned.apk 
+1
source

All Articles