I got UnsupportedClassVersionError when CircleCI runs gradle dependencies command. Here is an error that it shows:
FAILURE: Build failed with an exception.
- Where:
Build file ‘/home/ubuntu/MyProject/app/build.gradle’ line: 1
- What went wrong:
A problem occurred evaluating project ‘:app’.java.lang.UnsupportedClassVersionError: com/android/build/gradle/AppPlugin : Unsupported major.minor version 52.0
- Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 26.931 secs
export TERM=“dumb”
if [ -e ./gradlew ]; then ./gradlew dependencies;else gradle dependencies;fi
returned exit code 1
Action failed: gradle dependencies
Here is my configuration in .yml file:
machine:
java:
version: oraclejdk7
environment:
ANDROID_HOME: /usr/local/android-sdk-linux
dependencies:
pre:
- echo y | android update sdk --no-ui --all --filter “tools”
- echo y | android update sdk --no-ui --all --filter “platform-tools”
- echo y | android update sdk --no-ui --all --filter “build-tools”
- echo y | android update sdk --no-ui --all --filter “android-24”
- echo y | android update sdk --no-ui --all --filter “extra-google-m2repository”
- echo y | android update sdk --no-ui --all --filter “extra-google-google_play_services”
- echo y | android update sdk --no-ui --all --filter “extra-android-support”
- echo y | android update sdk --no-ui --all --filter “extra-android-m2repository”
- (./gradlew -version):
timeout: 360
#override:
#- ANDROID_HOME=/usr/local/android-sdk-linux ./gradlew dependencies
checkout:
post:
- git submodule init
- git submodule update
test:
override:
- (./gradlew assemble -PdisablePreDex):
timeout: 360
- cp -r ${HOME}/${CIRCLE_PROJECT_REPONAME}/app/build/outputs/apk/ $CIRCLE_ARTIFACTS
- emulator -avd circleci-android22 -no-audio -no-window:
background: true
parallel: true
# wait for it to have booted
- circle-android wait-for-boot
# run tests against the emulator.
- ./gradlew connectedAndroidTest
deployment:
staging:
branch: staging
commands:
- (./gradlew clean assembleStaging crashlyticsUploadDistributionStaging -PdisablePreFex):
timeout: 720
I also put compileOptions in build.gradle
android {
…
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
Have anyone faced this problem? Please advice.
Thanks.
FYI: dataBinding is enabled.