Error con java8 y Kotlin

Tengo una aplicación donde estoy usando retrolambda así que en build.gradle tengo

compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } 

Todo está bien a less que agregue el soporte para Kotlin. Al agregar el complemento de Kotlin, aparece el siguiente error:

Error: Error al convertir el bytecode a dex: Causa: Dex no puede analizar el código de bytes de la versión 52. Esto se debe a las dependencies de la biblioteca que se han comstackdo utilizando Java 8 o superior. Si está utilizando el complemento 'java' gradle en un submodule de biblioteca, agregue targetCompatibility = '1.7' sourceCompatibility = '1.7' al file build.gradle de ese submodule.

He encontrado muchas preguntas y respuestas similares a esta, pero ninguna de las soluciones se aplica en mi caso.

Este es mi build.gradle:

 buildscript { repositories { maven { url 'https://maven.fabric.io/public' } mavenCentral() } dependencies { classpath 'me.tatarka:gradle-retrolambda:3.3.1' classpath 'io.fabric.tools:gradle:1.+' } } repositories { // Requinetworking because retrolambda is on maven central mavenCentral() maven { url 'https://maven.fabric.io/public' } maven { url 'https://maven.google.com' } } apply plugin: 'com.android.application' apply plugin: 'io.fabric' apply plugin: 'realm-android' apply plugin: 'com.neenbedankt.android-apt' apply plugin: 'kotlin-android' plugins { id "me.tatarka.retrolambda" version "3.3.1" } android { compileSdkVersion 25 buildToolsVersion '25.0.2' compileOptions.incremental = false compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } defaultConfig { multiDexEnabled true applicationId "mypackage" minSdkVersion 17 targetSdkVersion 25 versionCode 1 versionName "0.1" vectorDrawables.useSupportLibrary = true jackOptions { enabled false } testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" dexOptions { preDexLibraries = false javaMaxHeapSize "4g" } } compileOptions { incremental true } buildTypes { release { debuggable false minifyEnabled true zipAlignEnabled true renderscriptDebuggable false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' signingConfig signingConfigs.release } debug { debuggable true signingConfig signingConfigs.debug minifyEnabled false versionNameSuffix "_dev" } } } def supportVersion = '25.3.1' dependencies { def daggerVer = 2.8 apt "com.google.dagger:dagger-compiler:$daggerVer" compile "com.google.dagger:dagger:$daggerVer" compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:multidex:1.0.1' compile "com.android.support:appcompat-v7:$supportVersion" compile "com.android.support:design:$supportVersion" compile "com.android.support:cardview-v7:$supportVersion" compile "com.android.support:recyclerview-v7:$supportVersion" compile "com.android.support:gridlayout-v7:$supportVersion" compile "com.android.support:support-annotations:$supportVersion" compile "com.android.support:preference-v7:$supportVersion" compile "com.android.support:support-v4:$supportVersion" compile "com.android.support:support-vector-drawable:$supportVersion" compile "com.android.support:palette-v7:$supportVersion" def firebase = '10.2.0' compile "com.google.firebase:firebase-crash:$firebase" compile "com.google.firebase:firebase-auth:$firebase" compile 'com.firebaseui:firebase-ui-auth:1.2.0' def rxbinding = '2.0.0' compile "com.jakewharton.rxbinding2:rxbinding:$rxbinding" compile "com.jakewharton.rxbinding2:rxbinding-support-v4:$rxbinding" compile "com.jakewharton.rxbinding2:rxbinding-appcompat-v7:$rxbinding" compile "com.jakewharton.rxbinding2:rxbinding-design:$rxbinding" compile "com.jakewharton.rxbinding2:rxbinding-recyclerview-v7:$rxbinding" compile "com.jakewharton.rxbinding2:rxbinding-leanback-v17:$rxbinding" compile 'joda-time:joda-time:2.5' compile 'com.ryanharter.auto.value:auto-value-parcel-adapter:0.2.5' compile 'com.jakewharton.timber:timber:4.3.1' compile 'com.github.bumptech.glide:glide:3.7.0' compile 'com.github.clans:fab:1.6.4' compile 'me.relex:circleindicator:1.2.2@aar' compile 'com.github.paolorotolo:appintro:4.1.0' //architecture compile "android.arch.lifecycle:runtime:1.0.0-alpha1" compile "android.arch.lifecycle:extensions:1.0.0-alpha1" annotationProcessor "android.arch.lifecycle:compiler:1.0.0-alpha1" def retrofit2 = '2.2.0' def okhttp3 = '3.4.1' compile "com.squareup.retrofit2:retrofit:$retrofit2" compile "com.squareup.retrofit2:adapter-rxjava2:$retrofit2" compile "com.squareup.retrofit2:converter-gson:$retrofit2" compile "com.squareup.retrofit2:converter-scalars:$retrofit2" compile "com.squareup.okhttp3:okhttp:$okhttp3" compile "com.squareup.okhttp3:okhttp-urlconnection:$okhttp3" compile "com.squareup.okhttp3:logging-interceptor:$okhttp3" compile 'com.github.franmontiel:PersistentCookieJar:v1.0.1' compile 'com.github.MFlisar:RxBus2:0.1' def butter_knife = '8.4.0' apt "com.jakewharton:butterknife-compiler:$butter_knife" compile "com.jakewharton:butterknife:$butter_knife" def leak_canary = '1.4' debugCompile "com.squareup.leakcanary:leakcanary-android:$leak_canary" releaseCompile "com.squareup.leakcanary:leakcanary-android-no-op:$leak_canary" testCompile "com.squareup.leakcanary:leakcanary-android-no-op:$leak_canary" apt 'com.gabrielittner.auto.value:auto-value-with:1.0.0' apt 'com.google.auto.value:auto-value:1.2' apt 'com.ryanharter.auto.value:auto-value-parcel:0.2.5' apt 'com.ryanharter.auto.value:auto-value-gson:0.3.2-rc1' provided 'javax.annotation:jsr250-api:1.0' provided 'com.google.auto.value:auto-value:1.2' compile 'com.braintreepayments.api:drop-in:3.0.6' //other dependencies for testing def hamcrestVersion = '1.3' testCompile "org.hamcrest:hamcrest-core:$hamcrestVersion" testCompile "org.hamcrest:hamcrest-library:$hamcrestVersion" testCompile "org.hamcrest:hamcrest-integration:$hamcrestVersion" androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) testCompile 'org.mockito:mockito-core:1.10.19' testCompile 'junit:junit:4.12' compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') { transitive = true; } compile 'com.android.support.constraint:constraint-layout:1.0.2' compile 'org.jetbrains:annotations:15.0' compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" } apply plugin: 'com.google.gms.google-services' android.packagingOptions { exclude 'LICENSE.txt' exclude 'META-INF/LICENSE.txt' exclude 'META-INF/NOTICE.txt' exclude 'META-INF/rxjava.properties' } configurations.all { resolutionStrategy.eachDependency { DependencyResolveDetails details -> def requested = details.requested if (requested.group == 'com.android.support') { if (!requested.name.startsWith("multidex")) { details.useVersion "$supportVersion" } } } } 

Sin éxito intenté esto

 tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { sourceCompatibility = JavaVersion.VERSION_1_6 targetCompatibility = JavaVersion.VERSION_1_6 kotlinOptions { jvmTarget = '1.6' apiVersion = '1.1' languageVersion = '1.1' } } 

y esto

 tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 kotlinOptions { jvmTarget = '1.8' apiVersion = '1.1' languageVersion = '1.1' } } 

Actualizo con la última versión que usa 1.8 para kotlin ahora recibo un error diferente:

Error: ejecución fallida para la tarea ': app: compileDebugKotlin'. Error de compilation. Ver logging para más detalles

Estoy investigando ahora

Este es mi build.gradle de nivel superior

 buildscript { ext.kotlin_version = '1.1.2-4' repositories { jcenter() } dependencies { classpath('com.android.tools.build:gradle:2.3.0') { force = true } // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle file classpath 'com.google.gms:google-services:3.0.0' classpath "io.realm:realm-gradle-plugin:2.1.1" classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } allprojects { repositories { jcenter() maven { url 'https://maven.fabric.io/public' } maven { url "https://jitpack.io" } } } task clean(type: Delete) { delete rootProject.buildDir }