François L. François L. - 11 months ago 142
Android Question

How to use Android Annotations and its annotation processor with jack?

Does anybody know how to use Android Annotations with the jack compiler ?

Here my app/build.gradle and here my project build.gradle

With this configuration, I have this error message when I build my project :

Error:Could not get unknown property 'classpath' for task ':app:transformJackWithJackForDebug' of type

Answer Source

You should remove the android-apt plugin and the apt block completely, because it does not work with Jack annotation processing. Also, you have to declare processsors in the annotationProcessor configuration. Lastly, you have to add the annotation processing parameters to jack (which has no public API per-variant, yet).

Here is your modified build.gradle:

repositories {

apply plugin: ''

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.2"
    defaultConfig {
        applicationId "com.frlgrd.streamzone"
        minSdkVersion 21
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner ""
        jackOptions {
            enabled true
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), ''

// Android Annotations
def AAVersion = '4.0.0'

dependencies {

    // Google
    androidTestCompile('', {
        exclude group: '', module: 'support-annotations'
    compile ''
    compile ''

    // Android Annotations
    annotationProcessor "org.androidannotations:androidannotations:$AAVersion"
    compile "org.androidannotations:androidannotations-api:$AAVersion"

    // RX
    compile 'com.tbruyelle.rxpermissions:rxpermissions:0.7.1@aar'
    compile 'io.reactivex:rxandroid:1.2.1'
    compile 'io.reactivex:rxjava:1.1.6'

// add annotation processing options to jack
android.applicationVariants.all { variant ->
            .arguments = ['androidManifestFile': variant.outputs[0]?.processResources?.manifestFile?.absolutePath]