Retrolambda:当使用retrolambda使用lambdaexpression式时,Lint崩溃

我正在尝试与gradle-retrolambda插件一起使用retrolambda 。 一般来说,它工作正常,但是当我编译发布, lint阶段失败,例外:

 :playground.dagger:lintVitalReleaseFailed converting ECJ parse tree to Lombok for file D:\....\playground\dagger\MainActivity.java java.lang.UnsupportedOperationException: Unknown ASTNode child: LambdaExpression at lombok.ast.ecj.EcjTreeVisitor.visitOther(EcjTreeVisitor.java:368) at lombok.ast.ecj.EcjTreeVisitor.visitEcjNode(EcjTreeVisitor.java:364) at lombok.ast.ecj.EcjTreeConverter.visit(EcjTreeConverter.java:295) at lombok.ast.ecj.EcjTreeConverter.toTree(EcjTreeConverter.java:236) at lombok.ast.ecj.EcjTreeConverter.fillList(EcjTreeConverter.java:282) at lombok.ast.ecj.EcjTreeConverter.fillList(EcjTreeConverter.java:252) at lombok.ast.ecj.EcjTreeConverter.access$100(EcjTreeConverter.java:141) at lombok.ast.ecj.EcjTreeConverter$2.visitMessageSend(EcjTreeConverter.java:1042) at lombok.ast.ecj.EcjTreeVisitor.visitEcjNode(EcjTreeVisitor.java:156) at lombok.ast.ecj.EcjTreeConverter.visit(EcjTreeConverter.java:295) at lombok.ast.ecj.EcjTreeConverter.toTree(EcjTreeConverter.java:236) at lombok.ast.ecj.EcjTreeConverter.fillList(EcjTreeConverter.java:282) at lombok.ast.ecj.EcjTreeConverter.fillList(EcjTreeConverter.java:252) at lombok.ast.ecj.EcjTreeConverter.toBlock(EcjTreeConverter.java:397) at lombok.ast.ecj.EcjTreeConverter.access$1500(EcjTreeConverter.java:141) at lombok.ast.ecj.EcjTreeConverter$2.visitMethodDeclaration(EcjTreeConverter.java:1241) at lombok.ast.ecj.EcjTreeVisitor.visitEcjNode(EcjTreeVisitor.java:152) at lombok.ast.ecj.EcjTreeConverter.visit(EcjTreeConverter.java:295) at lombok.ast.ecj.EcjTreeConverter.toTree(EcjTreeConverter.java:236) at lombok.ast.ecj.EcjTreeConverter.fillList(EcjTreeConverter.java:282) at lombok.ast.ecj.EcjTreeConverter.fillList(EcjTreeConverter.java:252) at lombok.ast.ecj.EcjTreeConverter.access$100(EcjTreeConverter.java:141) at lombok.ast.ecj.EcjTreeConverter$2.createNormalTypeBody(EcjTreeConverter.java:563) at lombok.ast.ecj.EcjTreeConverter$2.visitTypeDeclaration(EcjTreeConverter.java:486) at lombok.ast.ecj.EcjTreeVisitor.visitEcjNode(EcjTreeVisitor.java:48) at lombok.ast.ecj.EcjTreeConverter.visit(EcjTreeConverter.java:295) at lombok.ast.ecj.EcjTreeConverter.toTree(EcjTreeConverter.java:236) at lombok.ast.ecj.EcjTreeConverter.fillList(EcjTreeConverter.java:282) at lombok.ast.ecj.EcjTreeConverter.fillList(EcjTreeConverter.java:252) at lombok.ast.ecj.EcjTreeConverter.access$100(EcjTreeConverter.java:141) at lombok.ast.ecj.EcjTreeConverter$2.visitCompilationUnitDeclaration(EcjTreeConverter.java:441) at lombok.ast.ecj.EcjTreeVisitor.visitEcjNode(EcjTreeVisitor.java:264) at lombok.ast.ecj.EcjTreeConverter.visit(EcjTreeConverter.java:295) at com.android.tools.lint.EcjParser.parseJava(EcjParser.java:407) at com.android.tools.lint.client.api.JavaVisitor.visitFile(JavaVisitor.java:236) at com.android.tools.lint.client.api.LintDriver.checkJava(LintDriver.java:1491) at com.android.tools.lint.client.api.LintDriver.runFileDetectors(LintDriver.java:1026) at com.android.tools.lint.client.api.LintDriver.checkProject(LintDriver.java:882) at com.android.tools.lint.client.api.LintDriver.analyze(LintDriver.java:433) at com.android.tools.lint.client.api.LintDriver.analyze(LintDriver.java:374) at com.android.tools.lint.LintCliClient.run(LintCliClient.java:130) at com.android.build.gradle.internal.LintGradleClient.run(LintGradleClient.java:112) at com.android.build.gradle.internal.LintGradleClient$run.call(Unknown Source) at com.android.build.gradle.tasks.Lint.runLint(Lint.groovy:198) at com.android.build.gradle.tasks.Lint.this$4$runLint(Lint.groovy) at com.android.build.gradle.tasks.Lint$this$4$runLint$1.callCurrent(Unknown Source) at com.android.build.gradle.tasks.Lint.lintSingleVariant(Lint.groovy:173) at com.android.build.gradle.tasks.Lint$lintSingleVariant$0.callCurrent(Unknown Source) at com.android.build.gradle.tasks.Lint.lint(Lint.groovy:75) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:218) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:211) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:200) at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:579) at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:562) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46) at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35) at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64) at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58) at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42) at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52) at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53) at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43) at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:305) at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79) at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63) at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:23) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:88) at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:29) at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62) at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23) at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:68) at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32) at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62) at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:55) at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:149) at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106) at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86) at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:80) at org.gradle.tooling.internal.provider.BuildModelAction.run(BuildModelAction.java:43) at org.gradle.tooling.internal.provider.BuildModelAction.run(BuildModelAction.java:30) at org.gradle.tooling.internal.provider.ConfiguringBuildAction.run(ConfiguringBuildAction.java:119) at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:36) at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26) at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:47) at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119) at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:35) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119) at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:24) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119) at org.gradle.launcher.daemon.server.exec.StartStopIfBuildAndStop.execute(StartStopIfBuildAndStop.java:33) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119) at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:71) at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:69) at org.gradle.util.Swapper.swap(Swapper.java:38) at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:69) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119) at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60) at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119) at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:70) at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119) at org.gradle.launcher.daemon.server.exec.DaemonHygieneAction.execute(DaemonHygieneAction.java:39) at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:119) at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:46) at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:246) at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) 

有什么要做的吗? 当然,一个简单的工作/周围将是禁用lint检查释放。 但我正在寻找解决scheme,以保持lint

以下是应用程序的模块build.gradle

 apply plugin: 'com.android.application' apply plugin: 'me.tatarka.retrolambda' apply plugin: 'com.neenbedankt.android-apt' configurations { apt } android { compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } compileSdkVersion 22 buildToolsVersion "21.1.2" defaultConfig { minSdkVersion 10 targetSdkVersion 22 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled true shrinkResources true proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } } repositories { maven{ url 'https://oss.sonatype.org/content/repositories/snapshots/' } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:22.0.0' compile 'com.jakewharton:butterknife:6.1.0' compile 'com.google.dagger:dagger:2.0-SNAPSHOT' compile 'de.greenrobot:eventbus:2.4.0' retrolambdaConfig 'net.orfjackal.retrolambda:retrolambda:1.8.1' apt 'com.google.dagger:dagger-compiler:2.0-SNAPSHOT' provided 'org.glassfish:javax.annotation:10.0-b28' } 

build.gradle

 buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.1.0' classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4' classpath 'me.tatarka:gradle-retrolambda:2.5.0' } } allprojects { repositories { jcenter() } } 

你可以使用一个特殊的Lombok版本 ,不要抱怨Java 8的特性。

 buildscript { repositories { jcenter() ... } dependencies { classpath 'com.android.tools.build:gradle:<version>' classpath 'me.tatarka:gradle-retrolambda:<version>' classpath 'me.tatarka.retrolambda.projectlombok:lombok.ast:0.2.3.a2' } // Exclude the version that the android plugin depends on. configurations.classpath.exclude group: 'com.android.tools.external.lombok' } 

这样,即使使用最新版本的Android Gradle插件,您也可以在整个项目中保持运行lint。

注意:如果您收到相同的错误,请尝试将上面的configuration放在最上面的build.gradle文件中。 它应该工作。

有一个讨论这个问题的GitHub问题: https : //github.com/evant/gradle-retrolambda/issues/96

在这个问题中的一个意见提到, lint实际上从来没有用retrolambda工作过,而是用最新的lint版本,现在“失声”,而不是在遇到lambda时简单地跳过文件的其余部分。

考虑到这一点,似乎有两种select。 一个,你可以简单地禁用像你在你的问题中提到的lint 。 当然,这个问题是你会失去lint扫描你的其他代码的好处。 第二个select是回滚您的lint版本,使其不再“失声”,而是简单地跳过检查与lambda相关的源代码; 这样, lint仍然可以扫描应用程序源代码的其余部分。

根据GitHub的问题,从24.0.1 (你可能有不同的版本)回滚你的lint版本到24.0.0似乎可以解决这个问题。 你可以在问题中find这个信息(链接张贴在答案的开头)。

    Interesting Posts