evant / gradle-retrolambda

A gradle plugin for getting java lambda support in java 6, 7 and android
Apache License 2.0
5.3k stars 449 forks source link

retrolambda cause the build task stoping at javac #126

Closed endlforguiN closed 9 years ago

endlforguiN commented 9 years ago

Only 3.0.0 version of retrolambda can work for me, when > 3.0.0 the build task will stop after executed javac task ( to be exact after the lint task ) , also I execute the javac task independently ,and it is OK. I suspect the task list was broken because of something.But I cannot find a check method to solve it. My dev env is win7, AndroidStudio 1.4 beta . follow the guide I install java 8 sdk and set the JAVA8_HOME and the origin JAVA7_HOME in windows env path. I 'm sure the gradle script get the correct value for java home . If I create a demo project with 3.2.2, in AndroidStudio everything is OK. the build.gradle is

    apply plugin: 'com.android.application'
    apply plugin: 'me.tatarka.retrolambda'

    /**         //comment or not  doesn't work 
    retrolambda {
        jdk System.getenv("JAVA8_HOME")
        oldJdk System.getenv("JAVA7_HOME")
        javaVersion JavaVersion.VERSION_1_7
        //jvmArgs '-arg1', '-arg2'
        defaultMethods false
        incremental true
    }
     **/

    android {
        compileSdkVersion 22
        buildToolsVersion "23.0.0"

        defaultConfig {

            minSdkVersion 7
            targetSdkVersion 22
            versionCode 15
            versionName "1.8.2.25"

        }
        sourceSets {
            main {
                manifest.srcFile 'src/main/AndroidManifest.xml'
                java.srcDirs = ['src/main/java']
                renderscript.srcDirs = ['src/main']
                res.srcDirs = ['src/main/res']
                assets.srcDirs = ['src/main/assets']
                jniLibs.srcDirs = ['src/main/jniLibs']
                jni.srcDirs = [] 
            }
        }

        packagingOptions {
            exclude 'META-INF/DEPENDENCIES.txt'
            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/NOTICE.txt'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/DEPENDENCIES'
            exclude 'META-INF/notice.txt'
            exclude 'META-INF/license.txt'
            exclude 'META-INF/dependencies.txt'
            exclude 'META-INF/LGPL2.1'
            exclude 'META-INF/ASL2.0'

        }
        lintOptions {
            abortOnError false
        }
        dexOptions {
            //incremental true
            //preDexLibraries = false
            javaMaxHeapSize "4g"
        }
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
    }

    configurations.all {
        //check for updates every build
        resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
    }

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.jakewharton:butterknife:7.0.1'
        compile 'com.squareup.dagger:dagger:1.2.2'
        provided 'com.squareup.dagger:dagger-compiler:1.2.2'

        compile("com.alibaba:fastjson:1.1.45.android")
        compile 'de.greenrobot:eventbus:2.4.0'
        compile("com.squareup.picasso:picasso:2.5.2")

        compile 'com.belerweb:pinyin4j:2.5.0'
            /**
        compile ("com.facebook.stetho:stetho:1.1.1"){
    exclude   group:"com.squareup.dagger",module:"dagger-compiler"
         exclude group:"com.squareup.dagger" ,module:"dagger"
         exclude group:"com.google.code.findbugs" ,module:"jsr305"}  **/
    }

    tasks.withType(JavaCompile) {
        options.encoding = "UTF-8"
    }
evant commented 9 years ago

Looks like a duplicate of https://github.com/evant/gradle-retrolambda/issues/108

endlforguiN commented 9 years ago

@evant I have read #108 , because of Annotation Processing Tool of Dagger2 ???

intret commented 9 years ago

@endlforguiN Maybe I got the solution for the problem.

We known that Android Studio have two types of Module: 1. app Module; 2. library Module. I added this line

 apply plugin: 'me.tatarka.retrolambda'

to my app Module's Gradle file : app/build.gradle, but I forgot the library Module, and then I encountered the XxxxxJavac problem, it looks like this:

:model:compileDevelopmentDebugJavaWithJavac
编译器 (1.8.0_45) 中出现异常错误。 如果在 Bug Parade 中没有找到该错误, 请在 Java Developer Connection (http://java.sun.com/webapps/bugreport) 中建立 Bug。请在报告中附上您的程序和以下诊断信息。谢谢。
com.sun.tools.javac.code.Symbol$CompletionFailure: 找不到java.lang.invoke.MethodType的类文件

So, adding apply plugin: 'me.tatarka.retrolambda' to the library Module will solve it, if you have forgot it.

endlforguiN commented 9 years ago

@intret Thanks for you help !!!! I am so sorry for this belated Thanks... I forgot the password. =_= You save my lot of time . Thanks again.