2

build.gradle config:

apply plugin: 'com.android.application'
apply plugin: 'realm-android'
//apply plugin: 'android-apt'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.0"
    defaultConfig {
        applicationId "com.way.event"
        minSdkVersion 21
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        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(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.0.0'
    compile 'com.android.support:design:25.0.0'
    compile 'com.android.support:support-v4:25.0.0'
    testCompile 'junit:junit:4.12'
}

It didn't support Java8:

Error:Could not get unknown property 'classpath' for task ':app:transformJackWithJackForDebug' of type com.android.build.gradle.internal.pipeline.TransformTask.

Does it has anything to do with the Realm ? how to resolve it?

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Waylan Punch
  • 239
  • 4
  • 17

3 Answers3

5

Well, you can still use Retrolambda instead of Jack, nobody is stopping you from using lambdas.

buildscript {
    repositories {
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.0'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
        classpath "io.realm:realm-gradle-plugin:1.2.0"
        classpath 'me.tatarka:gradle-retrolambda:3.2.5'
    }
}

and

apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'realm-android'

android {
    compileSdkVersion xx
    buildToolsVersion "xx"

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

works just fine for Java 8 language features (lambdas, method references, try-with-resources).

EpicPandaForce
  • 79,669
  • 27
  • 256
  • 428
1

remove the previously dependent lambda library, because after 3.0, the AS itself supports the lambda.

Apply plugin: 'me.tatarka.retrolambda' //Remove this sentence

abbasalim
  • 3,118
  • 2
  • 23
  • 45
0

Thanks to @cricket_007

Support Jack compiler #3038

GitHub User @kirsting , he told me he can provide a solution to this problem. Check his comment on this issue below:

Java 1.8 and Android not working #2630

Waylan Punch
  • 239
  • 4
  • 17