10
votes

I would like to know what am I doing wrong in the Lombok setup for Android Studio 3.0 Beta 2?

That's how my Gradle build file looks like:

buildscript {
    repositories {
        mavenCentral()
        jcenter()
        maven { url "https://plugins.gradle.org/m2/" }
    }
    dependencies {
        classpath "io.franzbecker:gradle-lombok:1.10"
        classpath 'com.android.tools.build:gradle:2.3.3'
    }
}

allprojects {
    apply plugin: "eclipse"
    apply plugin: "idea"

    version = '1.0'
    ext {
        appName = "MyAppName"
        gdxVersion = '1.7.0'
    }

    repositories {
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        maven { url "https://oss.sonatype.org/content/repositories/releases/" }
    }
}

project(":desktop") {
    apply plugin: "java"


    dependencies {
        compile project(":core")
        compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
    }
}

project(":android") {
    apply plugin: "android"

    configurations { natives }

    dependencies {
        compile project(":core")
        compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
    }
}

project(":core") {
    apply plugin: "io.franzbecker.gradle-lombok"
    apply plugin: "java"

    dependencies {
        compile "com.badlogicgames.gdx:gdx:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
        compileOnly "org.projectlombok:lombok:1.16.18"
    }
}

tasks.eclipse.doLast {
    delete ".project"
}

I have installed the lombok plugin, and lombok stuff also shows up properly in the IDE, but when I want to build the project Gradle can not find the getters/setters created by Lombok. I tried to follow the tutorials from https://projectlombok.org/setup/android and other stack overflow pages about this setup, but nothing worked. In Android Studio 2.3 I couldn't even enable the annotation processing properly, that's why I updated to the latest beta version, where that at least works.

3
I assume you installed the plugin (Preferences.. -> Plugins) and annotation processing is enabled now? I just peeked at one of my projects wherein I am using Lombok and here are my Lombok related imports: compile 'org.projectlombok:lombok:1.16.16' compile 'javax.annotation:jsr250-api:1.0' provided 'javax.annotation:jsr250-api:1.0'lidkxx
I tried that, but it doesn't really work. Can you maybe send me one of your projects, without the actual src, so I could see the differences between it and between my setup?gyurix
Can't really do this right now, but I also noticed that I have a top level lombok.config file added (in my main/java folder) that has this line in it: lombok.anyConstructor.suppressConstructorProperties=truelidkxx
I tried it with the lombok.anyConstructor.suppressConstructorProperties=true, my project compiles but it wont generate any getters/setters/constructors. Nothing.最白目

3 Answers

4
votes

You need to use new annotationProcessor instead of apt : Gradle migration annotationProcessor

annotationProcessor "org.projectlombok:lombok:1.16.18"

I had the same problem as you and now it works.

7
votes

I have the same issue. At last I end up with this solution -

compileOnly 'org.projectlombok:lombok:1.16.18'
compileOnly 'javax.annotation:javax.annotation-api:1.3.1'
annotationProcessor 'org.projectlombok:lombok:1.16.18'
1
votes

I was facing the same issue where upgrading AS to 3.0 and Gradle to 4.1, lombok stopped generating setters/getters.

So If you are using lombok plugin with IntelliJ then for me downgrading lombok from latest stable edge release to 0.15.17.2 solved it.

This issue helped me solving it