Android development with lombok is possible. Lombok should be a compile-time only dependency, as otherwise the entirety of lombok will end up in your DEX files, wasting precious space on android devices. Also, errors will occur due to the native libraries present in lombok.jar itself. Unfortunately, android does not (yet) understand the concept of a compile-time-only dependency, so you need to mess with your build files to make it work.
Android also does not have a complete JRE library stack; in particular, it does not have the @java.beans.ConstructorProperties
annotation, therefore you have to stop lombok from generating these:
suppressConstructorProperties
property can be set to false
when using @XArgsConstructor Annotations.>= 1.14.0
you can instead a lombok.config
file to the root of your project to disable ConstructorProperties
project wide. Add the following line to lombok.config
:lombok.anyConstructor.suppressConstructorProperties = true
The instructions listed below are excerpts from The
AndroidAnnotations project cookbook. You may wish to refer to that documentation for complete instructions; lombok is just
the equivalent to androidannotations-VERSION.jar
; there is no -api
aspect.
java -jar lombok.jar publicApiThen, add the
lombok-api.jar
file created by running this command
to your android project instead of the complete lombok.jar
, and,
as usual, install lombok into eclipse by double-clicking lombok.jar
.
build.xml
in ${ANDROID_SDK_ROOT}/tools/ant/build.xml
and copy the -compile
target into the paste buffer.
build.xml
of your own project, right before the <import file="${sdk.dir}/tools/ant/build.xml">
line.
compile-libs
directory in your own project and copy the complete lombok.jar
to it.
<classpath>
entry inside the <javac>
task in the -compile
target you just copied:<fileset dir="compile-libs" includes="*.jar" />
to it.
lombok.jar
in your eclipse android project's build path
(which you can modify in that project's properties page) with lombok-api.jar
, as produced in the procedure explained for Eclipse,
above.
>= 0.4.3
dependencies
block:provided "org.projectlombok:lombok:1.12.6"
apt
directive) in the dependencies
block:provided "org.projectlombok:lombok:1.12.6" apt "org.projectlombok:lombok:1.12.6"
File > Settings > Plugins
Browse repositories...
Lombok Plugin
Install plugin