Lombok: support Android Databinding Library

Created on 7 Aug 2015  路  18Comments  路  Source: projectlombok/lombok

The Databinding library cannot find getter generated by lombok.

Imported like this:

dependencies {

    ......
    provided 'org.projectlombok:lombok:1.16.4'
}

Thanks.

Most helpful comment

@Shujito: THX for your suggestions!

I opted for option 3!

All 18 comments

Same issue here. Also using Dagger and EventBus to make things more interesting.

Full build.gradles: https://gist.github.com/bowmanb/7dcbb5de6609bfbca128

please, how can we fix this?

I confirm the problem with Android data binding.

Bump!

:+1: I'm encountering the same thing.

I know there are some problems if multiple annotation processors are involved. One way to handle those if to first run delombok on the whole codebase and feed the resulting files to the rest of the compilation process.

In a build.gradle file I wrote I used the following setup:

configurations {
    provided
    compileOnly.extendsFrom provided
    testCompile.extendsFrom compileOnly
}

dependencies {
    // other stuff
    compileOnly 'org.projectlombok:lombok:1.14.8'
}

task sourcesJar(type: Jar, dependsOn: classes) {
    classifier = 'sources'
    from sourceSets.main.allSource
}

sourceSets.main.compileClasspath += configurations.compileOnly

task myJavadoc(type: Javadoc) {
    source = sourceSets.main.allJava
    classpath = sourceSets.main.compileClasspath
    options.author = true
    options.links(project.ext.javadocLinks)
}

task javadocJar(type: Jar, dependsOn: myJavadoc) {
    classifier = 'javadoc'
    from javadoc.destinationDir
}

I hope this helps

@rspilker can you provide a working example? I tried your example above

up! @rspilker that code does not work for me. do you have a working example? thanks!

up? I also encountered this problem, the whole brain is already broken!

I have same issue...

I'm interested on this

Hey @rspilker can you please help us all ? :+1:

How to delombok with gradle 2.2? Thanks @rspilker!

Any update on this issue?
Did anyone maybe find a workaround for this issue?

@soldmachine: I can think of four workarounds:

  1. Not using lombok with databinding
  2. Not using databinding with lombok
  3. Use public fields
  4. Extend your class with annotations, then override the getters you want to use on the layout with databinding. This has worked nicely for me, the only issue with extending classes is that you'll have dupe code.

Hope this helps

@Shujito: THX for your suggestions!

I opted for option 3!

Looks like this is still an issue. Any solid work arounds besides public fields?

I found that lombok actually caused a memory leak with Android instant run, inflating my build times dramatically over the course of an hour. Due to that and other issues like this one, I've stopped using lombok, and found myself with a much more pleasant Android development experience.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rdsubhas picture rdsubhas  路  3Comments

lombokissues picture lombokissues  路  3Comments

merric picture merric  路  4Comments

michaelkuechler picture michaelkuechler  路  3Comments

jaschenk picture jaschenk  路  3Comments