Lombok Requires Annotation Processing

前端 未结 10 936
不思量自难忘°
不思量自难忘° 2020-12-16 09:04

I\'m using Android Studio 2.2 Preview 7, and the Lombok plugin suddenly started saying: Annotation processing seems to be disabled for the project X, and provid

相关标签:
10条回答
  • 2020-12-16 09:42

    Follow what setup manual says:

    Gradle Make sure that the version of your android plugin is >= 0.4.3 Use the gradle-lombok plugin. If you don't want to use the plugin, add Lombok to your application's dependencies block (requires Gradle v2.12 or newer):

    dependencies {    
     compileOnly "org.projectlombok:lombok:1.16.18" 
    }
    

    Android Studio Follow the previous instructions (Gradle). In addition to setting up your gradle project correctly, you need to add the Lombok IntelliJ plugin to add lombok support to Android Studio:

    1. Go to File > Settings > Plugins
    2. Click on Browse repositories...
    3. Search for Lombok Plugin
    4. Click on Install plugin Restart Android Studio

    https://projectlombok.org/setup/android

    0 讨论(0)
  • 2020-12-16 09:47

    With the newer gradle versions, it is enough to type these lines into the app's build.gradle's dependencies block:`

    compile "org.projectlombok:lombok:1.16.16"
    annotationProcessor "org.projectlombok:lombok:1.16.16"  
    

    Sync the project with the gradle and it will work.

    0 讨论(0)
  • 2020-12-16 09:48
    1. install Lombok plugin and restart
    2. add dependencies : https://projectlombok.org/setup/gradle

      compileOnly 'org.projectlombok:lombok:1.18.12' annotationProcessor 'org.projectlombok:lombok:1.18.12'

      testCompileOnly 'org.projectlombok:lombok:1.18.12' testAnnotationProcessor 'org.projectlombok:lombok:1.18.12'

    this is worked for me.

    0 讨论(0)
  • 2020-12-16 09:49

    The setup guide from the lombok website(lombok set up for android) says we should do two things

    1, install the lombok plugin

    2, add gradle dependencies

    dependencies {
      compileOnly 'org.projectlombok:lombok:1.18.6'
      annotationProcessor 'org.projectlombok:lombok:1.18.6'
    }
    

    But for me the plugin causes the problem to occur. After I disabled the plugin the error went away and lombok still works.

    0 讨论(0)
  • 2020-12-16 09:51

    Probably marked answer was sufficient at the time but I struggled a bit with android studio 3 and lombok 1.16.18. Anyway following worked for me

    in app > build.gradle add following

    compileOnly 'org.projectlombok:lombok:1.16.18'
    annotationProcessor 'org.projectlombok:lombok:1.16.18'
    

    you may start getting other errors so if you in your MyApplication > lombok.config add following lines

    lombok.addGeneratedAnnotation = false
    lombok.anyConstructor.suppressConstructorProperties = true
    

    if you don't have lombok.config just added it

    Above were suggested by the developer of lombok in following posts
    addGeneratedAnnotation
    suppressConstructorProperties

    0 讨论(0)
  • 2020-12-16 09:52

    In AndroidStudio 3.5+ do next steps:

    • go to File -> Other Settings -> Preferences for New Projects... (!)
    • expand Build, Execution, Deployment
    • expand Compiler
    • select Annotation Processors
    • check Enable annotation processing

    If it still wouldn't work just reinstall Lombok plugin.

    0 讨论(0)
提交回复
热议问题