nickcellar / annotation-processor-with-java8-jack-and-jill-android

Android Annotation Processor With Java8 and Jack&Jill
87 stars 6 forks source link

Android Annotation Processor
With Java8 and Jack&Jill CircleCI

Just a project to try out Android Annotation Processor in the new Java8 and Jack&Jill enviornment. Also check if libraries and testing frameworks work with it.

First of all, make sure you know what is JACK&JILL. Check this talk about The Jack and Jill Build System on Youtube.

Supported tools

Libraries

Testing frameworks

Project Set Up

/build.gradle

buildscript {
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.0-alpha4'
    }
}

/app/build.gradle

android {
    compileSdkVersion 24
    buildToolsVersion '24.0.0'
    defaultConfig {
        targetSdkVersion 24
        jackOptions {
            enabled true
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

Sample Dependencies

dependencies {
    // dagger 2
    compile 'com.google.dagger:dagger:2.5'
    annotationProcessor 'com.google.dagger:dagger-compiler:2.5'
    // auto-value
    compile 'com.google.auto.value:auto-value:1.2'
    annotationProcessor 'com.google.auto.value:auto-value:1.2'
    // butterknife
    compile 'com.jakewharton:butterknife:8.1.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.1.0'
    // logan square
    compile 'com.bluelinelabs:logansquare:1.3.6'
    annotationProcessor 'com.bluelinelabs:logansquare-compiler:1.3.6'
}

Issues

Stream API Only Supported In Android N

It is only supported if you set minSdkVersion to 24 or above.

Instant Run Not Supported

It is simply not supported now. Notification will be shown whenever you try to use it.

Data Binding Not Supported

If you put the following, error will be thrown.

android {
    dataBinding {
        enabled = true // Error: Data Binding does not support Jack builds yet
    }
}

Minifying For Tests Not Supported

If you put the following, error will be thrown.

Error:A problem occurred configuring project ':app'.
> Minifying the variant used for tests is not supported when using Jack.
android {
    testBuildType 'release'
    buildTypes {
        release {
            minifyEnabled true
            signingConfig signingConfigs.debug
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

Java 8 Stream API Not Working (fixed since 2.2.0-alpha4)

Stream api is not working working after upgrading to 2.2.0-alpha3, follow ticket. It means the following doesn't work:

Arrays.asList(3, 1, 2).stream()
    .sorted()
    .map(String::valueOf)
    .forEach(integer -> view.setText(view.getText() + " => " + integer));

Incorrect location for code generation (fixed since 2.2.0-alpha4)

Classes are generated in build/intermediates/classes/ instead of build/generated/source/, so they are not treated as source by Android Studio. Code referencing them will be displayed red. This issue has a temporary solution

Change Log

2016/6/25 - Android Plugin Updated

2016/6/13 - Android Plugin Updated

2016/6/2 - Temporary Solution

2016/6/1 - Android Plugin Updated

2016/5/23 - After Google IO