【问题标题】:Getting error "package lombok doesn't exist" with Android Studio 3 RC2使用 Android Studio 3 RC2 出现错误“lombok 包不存在”
【发布时间】:2017-10-22 14:36:19
【问题描述】:

我在尝试编译项目时收到以下错误:

错误:lombok 包不存在

还有其他人说找不到它的所有注释。

在编译之前我没有看到代码中的错误,而我在使用 Android Studio 3 RC1 时也没有出现此错误。

这是我的 gradle 脚本:

项目级别:

// 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
}

应用模块级:

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'
    }

我也有模块,但我认为这并不重要。

【问题讨论】:

    标签: java android lombok android-studio-3.0


    【解决方案1】:

    我希望是因为compileOnly 注释。这是文档: blog.gradle.org/introducing-compile-only-dependencies

    • 编译时需要但运行时从不需要的依赖项,例如仅源注解或注解处理器;

    • 编译时需要的依赖项,但只有在使用某些功能时才需要在运行时,也就是可选的依赖项;

    • 在编译时需要其 API 但其实现由消费库应用程序提供的依赖项
      或运行时环境。

    【讨论】:

      【解决方案2】:

      可能与jdk9有关。我知道 IntelliJ、lombok 1.16.18 和 jdk9 的组合目前不起作用。但这并不能解释您的错误消息。我们预计我们可以在几天内(可能是今晚)发布 1.16.20 来解决这个问题。

      披露:我是龙目岛开发人员。

      【讨论】:

      • 我实际上使用的是 Java 8,可以在 app.gradle 中看到。
      猜你喜欢
      • 2019-12-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-14
      • 2014-12-12
      • 1970-01-01
      • 1970-01-01
      • 2020-07-13
      相关资源
      最近更新 更多