5

Hello guys I desire to use lamba functions available on Java8, hence I had to apply new toolchain Jack. Unfortunatelly when I did some unexpected error arise. Namely:

Could not get unknown property 'classpath' for task ':app:transformJackWithJackForProdDebug' of type com.android.build.gradle.internal.pipeline.TransformTask. I'm using in my project library like

In project I'm using lib like:

  • dagger
  • RxJava

I know that dagger causes error, however since july dagger2 has became available to use.

I use

  • Android Studio 2.1.2
  • Gradle Version 2.14.1
  • Android Plugin Version 2.2.0-alpha7

Please look at my gradle

project/buidl.gradle

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.0-alpha7'
//        classpath 'com.android.tools.build:gradle:2.2.0-alpha3'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

app/build.gradle

apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'

android {
    compileSdkVersion 24  
    buildToolsVersion '24.0.0' 

    defaultConfig {
        applicationId "XXX"
        minSdkVersion 19
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"

        jackOptions{
            enabled true
        }
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
            minifyEnabled false
            versionNameSuffix "_debug"
        }
    }
    productFlavors{
        dev{
            minSdkVersion 21
        }
        prod {
            minSdkVersion 19
        }
    }
    compileOptions{
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

ext {
    JUNIT_VERSION = '4.12'
    DAGGER_VERSION = '2.4'
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile "junit:junit:$JUNIT_VERSION"
    compile project(path: ':android_mvp')
    // dependency injection
    apt 'com.google.dagger:dagger-compiler:2.0' // 2.5 causes error
    compile 'com.google.dagger:dagger:2.0'
    provided 'javax.annotation:jsr250-api:1.0'
    annotationProcessor 'com.google.dagger:dagger-compiler:2.0'
    // for new Jack and Jill gradle 2.2.+
    // rx java
    compile 'io.reactivex:rxjava:1.1.6'
    compile 'io.reactivex:rxandroid:1.2.1'
    // RxAndroid providing Android Scheduler
    compile 'io.reactivex:rxjava-joins:0.22.0'
    // view
    compile 'com.android.support:appcompat-v7:24.1.1'
    compile 'com.android.support:design:24.1.1'
    compile 'com.android.support:recyclerview-v7:24.1.1'
    compile 'com.android.support:cardview-v7:24.1.1'
    // rest / stream
    compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4'
    compile 'com.squareup.retrofit2:adapter-rxjava:2.0.0-beta4'
    compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta4'
    compile 'com.squareup.okhttp3:logging-interceptor:3.2.0'
    compile 'com.squareup.okhttp3:okhttp:3.2.0'
    compile 'com.neovisionaries:nv-websocket-client:1.29'
    // time
    compile 'net.danlew:android.joda:2.9.3'
}

EDITED

  1. Ok as I've read Lambdas are currenty not supported in project module, so as you want to use lambdas in project modules - just forget.
  2. So I've removed my own module and copied whole code into main app module
  3. I ended up with successfully gradle build by removing following code lines from app/build.gradle

apply plugin: 'com.neenbedankt.android-apt' ... dependency{ apt 'com.google.dagger:dagger-compiler:2.0' // 2.5 causes error }

  1. However error related with dagger remains, its mean that sometimes project was able to rebuild sometimes its wrote very long stacktrace.

CONCLUSION

After 2,5 years after first j8 release lazy Android team is not able to integrate it. 2,5 year in IT is sooo long, so my programing skils became slowly deprecated! I hope they finish until j9 release!

Community
  • 1
  • 1
murt
  • 3,790
  • 4
  • 37
  • 48
  • 2
    _"After 2,5 years after first j8 release lazy Android team is not able to integrate it."_ If you want to look at the real reason instead of just calling them lazy, then it's because Android historically has been using a variant of Apache's open-source "Harmony" Java implementation. Harmony was discontinued in 2011 at the point where it supported Java SE6, which is why Android has been stuck at Java 6 (with a few additions). Starting with Android N, Android will be switching from Harmony to OpenJDK, which should bring it up-to-date. – Michael Aug 05 '16 at 17:25
  • I made up your comment, thank you for answer. Nevertheless you just made me more anger, because they had 5,5 year to switch do more appropriate and up-to-date java variant. My whole studies least 5,5 year – murt Aug 05 '16 at 17:59
  • So you are telling me that new compile will now compromise between two java implementations. It is realy big deal? I suppose that both run on the same JVM, where are the differences @Michael – murt Aug 05 '16 at 18:02
  • As for why the switch hasn't happened earlier, I don't know. But given their still-ongoing legal dispute with Oracle over Java licensing I'd guess that Google would be _extremely_ cautious before making these kinds of decisions. – Michael Aug 05 '16 at 18:03

1 Answers1

18

Had the same issue. Solved by using built in "annotationProcessor" instead of "apt" plugin

https://stackoverflow.com/a/39086683/2282051

remove:

classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
apply plugin: 'com.neenbedankt.android-apt'
apt 'com.google.dagger:dagger-compiler:2.0'

and you already have

dependencies {
    annotationProcessor 'com.google.dagger:dagger-compiler:2.0'
}

It does the same as the 'apt' plugin does.

Community
  • 1
  • 1
Alireza Sobhani
  • 769
  • 1
  • 8
  • 18