Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move toward j8 and Jack. Gradle sync Error

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!

like image 793
murt Avatar asked Aug 04 '16 14:08

murt


1 Answers

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.

like image 198
Alireza Sobhani Avatar answered Oct 11 '22 15:10

Alireza Sobhani