Upgrading Android project to use Java8 (compileOptions cannot be applied to groovy.lang.closure)

Viewed 1850

I have made changes to build.gradle to upgrade my project, I am using Android Studio 2.1 Preview on MacOSX, this is my Gradle:

build.gradle.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 'android-N'
    buildToolsVersion '24.0.0 rc1'

    defaultConfig {
        applicationId "com.xxx.xxx"
        minSdkVersion 21
        targetSdkVersion 'N'
        versionCode 1
        versionName "1.0"
        jackOptions {
            enabled true
        }

    }
    compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.0.0-alpha1'
    compile 'com.android.support:design:24.0.0-alpha1'
    compile 'com.android.support:support-v4:24.0.0-alpha1'
    compile 'com.android.support:cardview-v7:24.0.0-alpha1'
    compile 'com.android.support:recyclerview-v7:24.0.0-alpha1'
}

Android Studio complains that 'compileOptions cannot be applied to groovy.lang.closure'

I installed the tools and SDK of Android N, and followed Google's instruction exactly Correct JDK pointed to

Edit: it stopped complaining, but Android visual designer gives the following error message:

Android N requires the IDE to be running with Java 1.8 or later

Install a supported JDK

1 Answers
Related