aboutsummaryrefslogtreecommitdiff
path: root/website/setup/android.html
blob: 17e821f57de525bd40bbdd7cc3aba1f65dd08d04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<!DOCTYPE html>
<html><head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<script src="../logi/jQuery-all.js" type="text/javascript"></script>
	<link rel="stylesheet" type="text/css" href="../logi/reset.css" />
	<link rel="stylesheet" type="text/css" href="../index.css" />
	<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
	<meta name="description" content="Spice up your java" />
	<title>Project Lombok</title>
	<!--[if lt IE 7]><script type="text/javascript" src="../logi/iepngfix_tilebg.js"></script><![endif]--> 
</head><body>
	<a id="forkMe" href="https://github.com/rzwitserloot/lombok"><img style="position: absolute; top: 0; right: 0; border: 0;" src="//s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" /></a>
	<div class="meat">
		<h1><a href="/">Project Lombok</a> - android instructions</h1>
		<div id="buttonBar" class="buttonBar">
			<a class="button" href="../features/index.html">
				<img src="../icon_overview.png" />
				<span>Feature Overview</span>
			</a>
			<a class="button" href="https://groups.google.com/group/project-lombok">
				<img src="../icon_discussion.png" />
				<span>Discuss / Help</span>
			</a>
			<a class="button" href="https://wiki.github.com/rzwitserloot/lombok/contributing">
				<img src="../icon_contribute.png" />
				<span>Contribute</span>
			</a>
			<a class="button" href="https://code.google.com/p/projectlombok/issues/list">
				<img src="../icon_bugs.png" />
				<span>Report an issue</span>
			</a>
			<div class="downloadContainer">
				<a class="downloadLink" id="downloadLink" href="../download.html">
					<img src="../icon_download.png" />
					<span>Download!</span>
				</a>
				<div class="versionInfo">
					Version: @VERSION@ | <a href="../changelog.html">changelog</a>
				</div>
			</div>
		</div>
		<div class="downloadHelp">
			<p>
			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.
			</p><p>
			Android also does not have a complete JRE library stack; in particular, it does not have the <code>@java.beans.ConstructorProperties</code> annotation, therefore you have to stop lombok from generating these:
				<ul>
					<li>The <code>suppressConstructorProperties</code> property can be set to <code>false</code> when using <a href="/features/Constructor.html">@XArgsConstructor Annotations</a>.</li>
					<li>Starting with Lombok <code>&gt;= 1.14.0</code> you can instead a <code>lombok.config</code> file to the root of your project to disable <code>ConstructorProperties</code> project wide. Add the following line to <code>lombok.config</code>:<br />
					<pre>lombok.anyConstructor.suppressConstructorProperties = true</pre><br />
					See the <a href="/features/configuration.html">configuration</a> documentation for more information on how to set up your project with a lombok config file.
				</ul>
			</p><p>
			The instructions listed below are excerpts from <a href="https://github.com/excilys/androidannotations/wiki/Cookbook">The
			AndroidAnnotations project cookbook</a>. You may wish to refer to that documentation for complete instructions; lombok is just
			the equivalent to <code>androidannotations-VERSION.jar</code>; there is no <code>-api</code> aspect.
			</p>
			<h3>Eclipse</h3>
			<div>
				In eclipse, create a 'lightweight' lombok jar that contains only the annotations by running:<br /><br />
				<pre>
java -jar lombok.jar publicApi</pre>
				Then, add the <code>lombok-api.jar</code> file created by running this command
				to your android project instead of the complete <code>lombok.jar</code>, and,
				as usual, install lombok into eclipse by double-clicking <code>lombok.jar</code>.
			</div>
			<h3>Ant</h3>
			<div>
				<ul>
					<li>Find <code>build.xml</code> in <code>${ANDROID_SDK_ROOT}/tools/ant/build.xml</code> and copy the <code>-compile</code> target into the paste buffer.
					<li>Copy this to the <code>build.xml</code> of your own project, right before the <code>&lt;import file="${sdk.dir}/tools/ant/build.xml"&gt;</code> line.
					<li>Create a <code>compile-libs</code> directory in your own project and copy the complete <code>lombok.jar</code> to it.
					<li>Now modify the <code>&lt;classpath&gt;</code> entry inside the <code>&lt;javac&gt;</code> task in the <code>-compile</code> target you just copied:<br />
						add <code>&lt;fileset dir="compile-libs" includes="*.jar" /&gt;</code> to it.
				</ul>
			</div>
			<h3>Maven</h3>
			<div>
				You should be able to just follow the normal <a href="../mavenrepo/index.html">lombok with maven instructions</a>.<br />
				Note that if you use android, eclipse, and maven together you may have to replace <code>lombok.jar</code> in your eclipse android project's build path
				(which you can modify in that project's properties page) with <code>lombok-api.jar</code>, as produced in the procedure explained for <em>Eclipse</em>,
				above.
			</div>
			<h3>Gradle</h3>
			<div>
				<ul>
					<li>Make sure that the version of your android plugin is <code>&gt;= 0.4.3</code></li>
					<li>Add Lombok to your application's <code>dependencies</code> block:<br /><br />
<pre>
	provided "org.projectlombok:lombok:1.12.6"
</pre>
					</li>
					<li>When using <a href="https://bitbucket.org/hvisser/android-apt">android-apt</a>, you also have to specify Lombok as an annotation processor (with the <code>apt</code> directive) in the <code>dependencies</code> block:<br  /><br />
<pre>
	provided "org.projectlombok:lombok:1.12.6"
	apt "org.projectlombok:lombok:1.12.6"
</pre>
					</li>
				</ul>
			</div>
			<h3>Android Studio</h3>
			<div>
				Follow the previous instructions (<em>Gradle</em>). In addition to setting up your gradle project correctly, you need to add the <a href="https://plugins.jetbrains.com/plugin/6317">Lombok IntelliJ plugin</a> to add lombok support to Android Studio:
				<ul>
					<li>Go to <code>File &gt; Settings &gt; Plugins</code></li>
					<li>Click on <code>Browse repositories...</code></li>
					<li>Search for <code>Lombok Plugin</code></li>
					<li>Click on <code>Install plugin</code></li>
					<li>Restart Android Studio</li>
				</ul>
			</div>
		<div class="endBar">
		</div>
		<div class="footer">
			<a href="../credits.html" class="creditsLink">credits</a> | Copyright &copy; 2009-2015 The Project Lombok Authors, licensed under the <a href="http://www.opensource.org/licenses/mit-license.php">MIT license</a>.
		</div>
	</div>
	<script type="text/javascript">
		var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
		document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
	</script>
	<script type="text/javascript">
		try {
			var pageTracker = _gat._getTracker("UA-9884254-1");
			pageTracker._trackPageview();
		} catch(err) {}
	</script>
</body></html>