Lombok issue - Could not find org.projectlombok

Viewed 5103

I get the following error, on a fresh android project with 2 modules and with just 5-6 new classes.

Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not find org.projectlombok:lombok:.
     Required by:
         project :app

Possible solution:
 - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html

I cannot figure out what is going on, both of build.gradle files contain the lombok dependency

dependencies {
...
    compileOnly 'org.projectlombok:lombok:1.18.16'
    annotationProcessor 'org.projectlombok:lombok:1.18.16'
}
3 Answers

If on Android Studio, you may want to check the following:

  • that annotation processing is enabled (Settings > Build, Execution, Deployment > Compiler > Annotation Processors.)

  • that no extra lombok dependencies were inadvertently added to the build.gradle files besides the two you already listed. In my case I found an extra implementation 'org.projectlombok:lombok:1.18.20' dependency in app build.gradle file.

  • that mavenCentral() is added to the list of repositories as below:

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

After fixing those 3 issues lombok worked fine for me.

I had this issue when I was using an implementation platform("org.springframework.boot:spring-boot-dependencies:<VERSION>") call in the dependencies block of a build.gradle file.

The issue was that it was applying the version automatically to my compileOnly "org.projectlombok:lombok" call but not annotationProcessor "org.projectlombok:lombok" call. I discovered this when running the depdendencies Gradle task on the project.

I'm still looking into why it isn't working for annotationProcessor definitions, but a workaround is to specify a version number in both the compileOnly and annotationProcessor calls and keep them in sync.

Related