16

I'm trying to build using Travis CI on my Android project with this .travis.yml file

language: android
android:
  components:
    - platform-tools
    - tools
    - build-tools-23.0.3
    - android-23
    - sys-img-armeabi-v7a-android-23
    - sys-img-x86-android-23    

Here is my app level build.gradle:

apply plugin: 'com.android.application'


android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"
    defaultConfig {
        applicationId "com.myname.myproject"
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    debug{
        testCoverageEnabled = true
    }
}} 

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'

testCompile "org.robolectric:robolectric:3.1.2"
testCompile 'org.khronos:opengl-api:gl1.1-android-2.1_r1'
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'

androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})

}

I am getting this failure message on Travis CI:

FAILURE: Build failed with an exception.
* Where:
Build file '/home/travis/build/myname/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

From the error, it seems that it has something to do with the Java version. I notice that Travis uses Java version 1.7.0_76.

I have tried some of the solutions at Unsupported major.minor version 52.0 in my app. None of them have worked for me. For instance, this doesn't seem to work:

android {
...
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_7
    targetCompatibility JavaVersion.VERSION_1_7
}

}

UPDATE: I fixed this by adding jdk: oraclejdk8 to the second line of my .travis.yml file after language:android

Community
  • 1
  • 1
VIN
  • 6,385
  • 7
  • 38
  • 77

1 Answers1

28

UPDATE: I fixed this by adding jdk: oraclejdk8 to the second line of my .travis.yml file after language:android

VIN
  • 6,385
  • 7
  • 38
  • 77