Home » Android » Getting error “package lombok doesn't exist” with Android Stuido 3 RC2

Getting error “package lombok doesn't exist” with Android Stuido 3 RC2

Posted by: admin November 1, 2017 Leave a comment

Questions:

I am getting the following error when trying to compile the project:

error: package lombok does not exist

And others stating that all the annotations from it can’t be found.

I don’t see errors in code before compiling and I didn’t have this error while I was using Android Studio 3 RC1.

Here are my gradle scripts:

Project level:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-rc2'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

App module level:

apply plugin: 'com.android.application'

android {
        compileSdkVersion 26
        buildToolsVersion "26.0.2"
        defaultConfig {
            applicationId "com.mk.forum"
            minSdkVersion 25
            targetSdkVersion 26
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }

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

    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'com.android.support:appcompat-v7:26.1.0'
        implementation 'com.android.support.constraint:constraint-layout:1.0.2'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'com.android.support.test:runner:1.0.1'
        androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
        compile project (':util')
        compile project (':forum_core')
        compileOnly 'org.projectlombok:lombok:1.16.18'
        annotationProcessor 'org.projectlombok:lombok:1.16.18'
        compile group: 'com.github.javafaker', name: 'javafaker', version: '0.13'
    }

I’ve got modules too, but I think it isn’t important.

Answers:

I hope it is because of compileOnly annotation. Here is the doc:
blog.gradle.org/introducing-compile-only-dependencies

  • Dependencies required at compile time but never required at runtime, such as source-only annotations or annotation processors;

  • Dependencies required at compile time but required at runtime only when using certain features, a.k.a. optional dependencies;

  • Dependencies whose API is required at compile time but whose implementation is to be provided by a consuming library, application
    or runtime environment.

Questions:
Answers:

It might be related to jdk9. I know that the combination of IntelliJ, lombok 1.16.18 and jdk9 currently doesn’t work. But that does not explain your error message. We expect that we can release 1.16.20 within a few days (maybe tonight) that addresses this problem.

Disclosure: I am a lombok developer.