Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnsupportedOperationException: Unknown ASTNode child: LambdaExpression #10

Open
caipivara opened this Issue Nov 6, 2015 · 15 comments

Comments

Projects
None yet
8 participants
@caipivara
Copy link

caipivara commented Nov 6, 2015

From evant/gradle-retrolambda#140.

Using:

  • Android studio 1.4.1
  • Android gradle plugin 1.3.1
  • Gradle 2.8

I get an error from lint when I try to run ./gradle assemble or ./gradlew lint
I'm using gradle 2.8 and android gradle plugin 1.3.1 and this is my build file:

buildscript {
  repositories {
    mavenCentral()
    jcenter()
    maven { url 'https://maven.fabric.io/public' }
  }

  dependencies {
    classpath 'me.tatarka:gradle-retrolambda:3.2.3'
    classpath 'me.tatarka.retrolambda.projectlombok:lombok.ast:0.2.3.a2'
    classpath 'io.fabric.tools:gradle:1.20.1'
  }

  // Retrolambda/lombok
  configurations.classpath.exclude group: 'com.android.tools.external.lombok'
}

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

def gitSha = 'git rev-parse --short HEAD'.execute([], project.rootDir).text.trim()
def appVersionName = "0.3.0"
def appVersionCode = 3

android {
  compileSdkVersion 23
  buildToolsVersion "23.0.1"

  defaultConfig {
    applicationId appId
    minSdkVersion 15
    targetSdkVersion 23
    versionCode appVersionCode
    versionName appVersionName
  }

  buildTypes {
    debug {
      buildConfigField "boolean", "DEBUGGING", "true"

      minifyEnabled false
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    staging {
      buildConfigField "boolean", "DEBUGGING", "true"

      signingConfig signingConfigs.release
      minifyEnabled false
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
    release {
      signingConfig signingConfigs.release

      minifyEnabled false
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
  }

  // Retrolambda
  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }
}

repositories {
  mavenCentral()
  maven { url 'https://maven.fabric.io/public' }
}

ext {
  supportLibVersion = '23.1.0'
}

dependencies {
  compile "com.android.support:appcompat-v7:${supportLibVersion}"
  compile "com.android.support:support-annotations:${supportLibVersion}"
  compile "com.android.support:design:${supportLibVersion}"

  // Base
  compile project(':api')
  compile 'com.jakewharton:butterknife:7.0.1'
  compile 'com.jakewharton.timber:timber:4.1.0@aar'
  compile 'de.greenrobot:eventbus:2.4.0'

  debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
  stagingCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'
  releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'

  // UI
  compile 'fr.avianey.com.viewpagerindicator:library:2.4.1@aar'
  compile('com.mikepenz:materialdrawer:4.4.4@aar') { transitive = true }
  compile 'com.squareup.picasso:picasso:2.5.2'
  compile 'com.sothree.slidinguppanel:library:3.2.0'

  // Management
  compile('com.crashlytics.sdk.android:crashlytics:2.5.2@aar') { transitive = true; }

  testCompile 'junit:junit:4.12'
  testCompile "org.mockito:mockito-core:1.10.19"
  testCompile('com.squareup.assertj:assertj-android:1.1.0') {
    exclude group: 'com.android.support', module: 'support-annotations'
  }
}

and my lint.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<lint>
  <!-- Retrolambda/lombok -->
  <issue id="NewApi">
    <ignore regexp="Try-with-resources requires API level 19" />
  </issue>
</lint>

If I run ./gradlew assemble I still get a lot of:

Failed converting ECJ parse tree to Lombok for file .../sign_up/SignUpPresenter.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.toTree(EcjTreeConverter.java:229)
        at lombok.ast.ecj.EcjTreeConverter.createVariableDefinition(EcjTreeConverter.java:352)
        at lombok.ast.ecj.EcjTreeConverter.toVariableDefinition(EcjTreeConverter.java:305)
        at lombok.ast.ecj.EcjTreeConverter.fillList(EcjTreeConverter.java:280)
        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:412)
        at com.android.tools.lint.client.api.JavaVisitor.visitFile(JavaVisitor.java:245)
        at com.android.tools.lint.client.api.LintDriver.checkJava(LintDriver.java:1503)
        at com.android.tools.lint.client.api.LintDriver.runFileDetectors(LintDriver.java:1037)
        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:128)
        at com.android.build.gradle.internal.LintGradleClient.run(LintGradleClient.java:112)
        at com.android.build.gradle.internal.LintGradleClient$run.call(Unknown Source)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
        at com.android.build.gradle.tasks.Lint.runLint(Lint.groovy:203)
        at com.android.build.gradle.tasks.Lint.this$5$runLint(Lint.groovy)
        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:497)
        at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210)
        at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:182)
        at com.android.build.gradle.tasks.Lint.lintSingleVariant(Lint.groovy:178)
        at com.android.build.gradle.tasks.Lint$lintSingleVariant$3.callCurrent(Unknown Source)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:174)
        at com.android.build.gradle.tasks.Lint.lint(Lint.groovy:80)
        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:497)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:227)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:220)
        at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:209)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:585)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:568)
        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:52)
        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.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:62)
        at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
        at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
        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)

As @evant said I runed

task printBuildScriptClasspath << {
    println project.buildscript.configurations.classpath.asPath
}

and the output is:

/Users/danielgomez22/.gradle/caches/modules-2/files-2.1/me.tatarka/gradle-retrolambda/3.2.3/f8c72225ddc48f40ec671a985e796256c809e92/gradle-retrolambda-3.2.3.jar:/Users/danielgomez22/.gradle/caches/modules-2/files-2.1/me.tatarka.retrolambda.projectlombok/lombok.ast/0.2.3.a2/e649c244b625ffb9021b3f6debde350a74e46b62/lombok.ast-0.2.3.a2.jar:/Users/danielgomez22/.gradle/caches/modules-2/files-2.1/io.fabric.tools/gradle/1.20.1/f3fc9824abcb0f8681ed019d599232dc4d37e5c2/gradle-1.20.1.jar

@ciprig

This comment has been minimized.

Copy link

ciprig commented Nov 8, 2015

I had the same annoying problem.
The way to solve it is to move all build scripts from module build.gradle to project build.gradle

@caipivara

This comment has been minimized.

Copy link
Author

caipivara commented Nov 9, 2015

all build scripts? @ciprig

@ciprig

This comment has been minimized.

Copy link

ciprig commented Nov 15, 2015

Yes all

@dmitry-mochalov

This comment has been minimized.

Copy link

dmitry-mochalov commented Nov 17, 2015

@danielgomezrico have you found a solution?

@caipivara

This comment has been minimized.

Copy link
Author

caipivara commented Nov 18, 2015

Nope

@caipivara

This comment has been minimized.

Copy link
Author

caipivara commented Nov 18, 2015

@ciprig but which build scripts?

@nevir

This comment has been minimized.

Copy link

nevir commented Dec 23, 2015

Moving the entire buildscript section into the project configuration works for me as well. Sucks, but good enough!

@realdadfish

This comment has been minimized.

Copy link

realdadfish commented Jan 22, 2016

I don't have another buildscript section other than in my root project's build.gradle file and face the same problem (build tools 1.5.0).

What I found weird though is that lombok is not at all listed as dependency for lint when I execute the following task:

task buildScriptDependencies(type: org.gradle.api.tasks.diagnostics.DependencyReportTask) {
    configurations = project.buildscript.configurations
}

It shows me

<snip>
|         +--- com.android.tools.lint:lint:24.5.0
|         |    +--- com.android.tools.lint:lint-checks:24.5.0
|         |    |    +--- com.android.tools.lint:lint-api:24.5.0
|         |    |    |    +--- com.android.tools:sdk-common:24.5.0 (*)
|         |    |    |    +--- com.android.tools.build:builder-model:1.5.0 (*)
|         |    |    |    +--- org.ow2.asm:asm:5.0.3
|         |    |    |    \--- org.ow2.asm:asm-tree:5.0.3 (*)
|         |    |    \--- org.ow2.asm:asm-analysis:5.0.3
|         |    |         \--- org.ow2.asm:asm-tree:5.0.3 (*)
|         |    \--- org.eclipse.jdt.core.compiler:ecj:4.4.2
<snip>

Is this correct?

@realdadfish

This comment has been minimized.

Copy link

realdadfish commented Jan 25, 2016

Don't mind me, that only proved that configurations.classpath.exclude group: 'com.android.tools.external.lombok'worked as expected x)

@caipivara

This comment has been minimized.

Copy link
Author

caipivara commented Jan 26, 2016

@tommyd3mdi can you explain how you make it work?

@realdadfish

This comment has been minimized.

Copy link

realdadfish commented Jan 30, 2016

@danielgomezrico Still haven't gotten it to work :(

@caipivara

This comment has been minimized.

Copy link
Author

caipivara commented Feb 3, 2016

@tommyd3mdi ah ok :(

@ondroEd

This comment has been minimized.

Copy link

ondroEd commented Feb 4, 2016

Sorry, I HAD the same problem with 3.2.4, but ciprig's advice solves the issue.
If you have two java versions 7 and 8 like I have, set 'org.gradle.java.home' value to java 8 jdk path in gradle.properties

@hannesstruss

This comment has been minimized.

Copy link

hannesstruss commented Feb 11, 2016

@ciprig's advice worked for me as well, but it was enough to move these lines to the root project's build.gradle:

//...
    classpath 'me.tatarka.retrolambda.projectlombok:lombok.ast:0.2.3.a2'
}
configurations.classpath.exclude group: 'com.android.tools.external.lombok'
//...
@gregbacchus

This comment has been minimized.

Copy link

gregbacchus commented Apr 27, 2016

@hannesstruss that worked for me (also referenced in http://stackoverflow.com/a/30536556/48225)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.