走向j8和杰克.Gradle sync错误

mur*_*urt 5 android android-studio android-gradle-plugin gradle-plugin

大家好我想使用Java8上提供的lamba函数,因此我不得不应用新的工具链Jack.不幸的是,当我做了一些意外的错误时出现了.即:

无法获取com.android.build.gradle.internal.pipeline.TransformTask类型的任务':app:transformJackWithJackForProdDebug'的未知属性'classpath'.我正在我的项目库中使用

在项目中我使用lib如:

  • 匕首
  • RxJava

我知道匕首会导致错误,但是自7月以来dagger2 已经可以使用了.

我用

  • Android Studio 2.1.2
  • Gradle版本2.14.1
  • Android插件版本2.2.0-alpha7

请看我的gradle

项目/ 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
}
Run Code Online (Sandbox Code Playgroud)

应用程序/的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'
}
Run Code Online (Sandbox Code Playgroud)

EDITED

  1. 好的,因为我读过项目模块中不支持Lambdas,因此你想在项目模块中使用lambdas - 只是忘了.
  2. 所以我删除了自己的模块并将整个代码复制到主app模块中
  3. 我最终成功地通过从app/build.gradle中删除以下代码行来构建gradle

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

  1. 然而,与匕首相关的错误仍然存​​在,这意味着有时项目有时能够重建其写的非常长的堆栈跟踪.

结论

在第一次发布j8之后的2.5年之后,懒惰的Android团队无法集成它.2.5年的IT时间太长了,所以我的编程技巧慢慢被弃用了!我希望他们完成直到j9发布!

Ali*_*ani 18

有同样的问题.通过使用内置的"annotationProcessor"而不是"apt"插件解决

/sf/answers/2736067841/

去掉:

classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
apply plugin: 'com.neenbedankt.android-apt'
apt 'com.google.dagger:dagger-compiler:2.0'
Run Code Online (Sandbox Code Playgroud)

而你已经拥有了

dependencies {
    annotationProcessor 'com.google.dagger:dagger-compiler:2.0'
}
Run Code Online (Sandbox Code Playgroud)

它与'apt'插件的作用相同.