summaryrefslogtreecommitdiffstats
path: root/docs/html/tools/revisions/gradle-plugin.jd
blob: 8713e6b0ed7844f30625621e402c7ed864fcf717 (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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
page.title=Android Plugin for Gradle Release Notes

@jd:body

<div id="qv-wrapper">
<div id="qv">

  <h2>See also</h2>
  <ol>
     <li><a href="{@docRoot}sdk/installing/studio-build.html">Build System Overview</a></li>
     <li><a href="{@docRoot}tools/building/plugin-for-gradle.html">Android Plugin for Gradle</a></li>
  </ol>

</div>
</div>


<p>The Android build system uses the Android Plugin for Gradle to support building Android
applications with the <a href="http://www.gradle.org/">Gradle</a> build toolkit. The plugin runs
independent of Android Studio so the plugin and the Gradle build system can be updated
independently of Android Studio.</p>

<p class="note"><strong>Note:</strong> When you update Android Studio or open a project in a
previous version of Android Studio, Android Studio prompts you to automatically update the plugin
and Gradle to the latest available versions. You can choose to accept these updates based
on your project's build requirements. </p>


<h2 id="revisions">Revisions</h2>

<p>The sections below provide notes about successive releases of
the Android Plugin for Gradle, as denoted by revision number. To determine what revision of the
plugin you are using, check the version declaration in the project-level
<strong>build.gradle</strong> file. </p>

<p>For a summary of known issues in Android Plugin for Gradle, see <a
href="http://tools.android.com/knownissues">http://tools.android.com/knownissues</a>.</p>


<div class="toggle-content opened">
  <p><a href="#" onclick="return toggleContent(this)">
    <img src="{@docRoot}assets/images/triangle-opened.png" class="toggle-content-img"
      alt=""/>Android Plugin for Gradle, Revision 1.3.0</a> <em>(July 2015)</em>
  </p>

  <div class="toggle-content-toggleme">

    <dl>
    <dt>Dependencies:</dt>

    <dd>
      <ul>
        <li>Gradle 2.2.1 or higher.</li>
        <li>Build Tools 21.1.1 or higher.</li>
      </ul>
    </dd>

    <dt>General Notes:</dt>
    <dd>
      <ul>
      <li>Added support for the <code>com.android.build.threadPoolSize</code> property to control
         the <code>Android</code> task thread pool size from the <code>build.gradle</code> file or
         the command line. The following example sets this property to 4.
<pre>
-Pcom.android.build.threadPoolSize=4
</pre>
      </li>
      <li>Set the default build behavior to exclude <code>LICENSE</code> and <code>LICENSE.txt</code>
        files from APKs. To include these files in an APK, remove these files from the
        <code>packagingOptions.excludes</code> property in the <code>build.gradle</code> file.
        For example:
<pre>
android {
      packagingOptions.excludes = []
    }
</pre>
      </li>
      <li>Added the <code>sourceSets</code> task to inspect the set of all available source sets. </li>
      <li>Enhanced unit test support to recognize multi-flavor and
        <a href="{@docRoot}tools/building/configuring-gradle.html#workBuildVariants">
        build variant</a>  source folders. For example, to test an app with multi-flavors
        <code>flavor1</code> and <code>flavorA</code> with the <code>Debug</code> build type,
        the test source sets are:
        <ul>
          <li>test </li>
          <li>testFlavor1 </li>
          <li>testFlavorA </li>
          <li>testFlavor1FlavorA </li>
          <li>testFlavor1FlavorADebug </li>
        </ul>
        <p>Android tests already recognized multi-flavor source folders. </p> </li>
      <li>Improved unit test support to:</p>
        <ul>
          <li>Run <code>javac</code> on main and test sources, even if the <code>useJack</code>
            property is set to <code>true</code> in your build file. </li>
          <li>Correctly recognize dependencies for each build type. </li>
        </ul>
      </li>
      <li>Added support for specifying instrumentation test-runner arguments from the command line.
        For example:
<pre>
./gradlew connectedCheck \
   -Pandroid.testInstrumentationRunnerArguments.size=medium \
   -Pandroid.testInstrumentationRunnerArguments.class=TestA,TestB
</pre>
      </li>
      <li>Added support for arbitrary additional Android Asset Packaging Tool (AAPT) parameters
        in the <code>build.gradle</code> file. For example:
<pre>
android {
    aaptOptions {
      additionalParameters "--custom_option", "value"
    }
}
</pre>
      </li>

      <li>Added support for a <a href="{@docRoot}tools/studio/studio-features.html#test-module">
        test APK module</a> as a separate test module, using the
        <code>targetProjectPath</code> and <code>targetVariant</code> properties to set the APK
        path and target variant.
         <p class="note"><strong>Note:</strong> A test APK module does not support product
          flavors and can only target a single variant. Also, Jacoco is not supported yet.</p>
      </li>
      <li>Added resource name validation before merging resources. </li>
      <li>When building an AAR (Android ARchive) package for library modules, do not provide an
        automatic <code>&#64;{applicationId}</code> placeholder in the
        <a href="{@docRoot}tools/building/manifest-merge.html">manifest merger</a> settings.
        Instead, use a different placeholder, such as <code>&#64;{libApplicationId}</code> and
        provide a value for it if you want to include application Ids in the archive library.  </li>

     </ul>
    </dd>
  </div>
</div>




<div class="toggle-content closed">
  <p><a href="#" onclick="return toggleContent(this)">
    <img src="{@docRoot}assets/images/triangle-closed.png" class="toggle-content-img"
      alt=""/>Android Plugin for Gradle, Revision 1.2.0</a> <em>(April 2015)</em>
  </p>

  <div class="toggle-content-toggleme">

    <dl>
    <dt>Dependencies:</dt>

    <dd>
      <ul>
        <li>Gradle 2.2.1 or higher.</li>
        <li>Build Tools 21.1.1 or higher.</li>
      </ul>
    </dd>

    <dt>General Notes:</dt>
    <dd>
      <ul>
      <li>Enhanced support for running unit tests with Gradle.  </li>
        <ul>
          <li>Added support to include Java-style resources in the classpath when running unit
            tests directly from Gradle.
          </li>
          <li>Added unit test dependency support for Android ARchive (AAR) artifacts.
          </li>
          <li>Added support for the <code>unitTestVariants</code> property so unit test variants
            can be manipulated using the <code>build.gradle</code> file.
          </li>
          <li>Added the <code>unitTest.all</code> code block under <code>testOptions</code> to
            configure customized tasks for unit test. The following sample code shows how to add
            unit test configuration settings using this new option:
<pre>
android {
  testOptions {
    unitTest.all {
      jvmArgs '-XX:MaxPermSize=256m' // Or any other gradle option.
    }
  }
}
</pre>
           </li>
          <li>Fixed the handling of enums and public instance fields in the packaging of the
           <code>mockable-android.jar</code> file.
          </li>
          <li>Fixed library project task dependencies so test classes recompile after changes.
          </li>
          </ul>
        <li>Added the <code>testProguardFile</code> property to apply
          <a href="{@docRoot}tools/help/proguard.html">ProGuard</a> files when minifying a test APK.
        </li>
        <li>Added the <code>timeOut</code> property to the <code>adbOptions</code> code block
          for setting the maximum recording time for
          <a href="{@docRoot}tools/help/adb.html">Android Debug Bridge</a> screen recording.
        </li>
        <li>Added support for 280 dpi resources.
        </li>
        <li>Improved performance during project evaluation.
        </li>
     </ul>
    </dd>
  </div>
</div>


<div class="toggle-content closed">
  <p><a href="#" onclick="return toggleContent(this)">
    <img src="{@docRoot}assets/images/triangle-closed.png" class="toggle-content-img"
      alt=""/>Android Plugin for Gradle, Revision 1.1.3</a> <em>(March 2015)</em>
  </p>

  <div class="toggle-content-toggleme">

    <dl>
    <dt>Dependencies:</dt>

    <dd>
      <ul>
        <li>Gradle 2.2.1 or higher.</li>
        <li>Build Tools 21.1.1 or higher.</li>
      </ul>
    </dd>

    <dt>General Notes:</dt>
    <dd>
    <ul>
      <li>Fixed issue with duplicated dependencies on a test app that triggered a ProGuard failure. </li>
      <li>Fixed Comparator implementation which did not comply with the JDK Comparator contract and
      generated a JDK 7 error.</li>
    </ul>
    </dd>
  </div>
</div>


<div class="toggle-content closed">
  <p><a href="#" onclick="return toggleContent(this)">
    <img src="{@docRoot}assets/images/triangle-closed.png" class="toggle-content-img"
      alt=""/>Android Plugin for Gradle, Revision 1.1.2</a> <em>(February 2015)</em>
  </p>

  <div class="toggle-content-toggleme">

    <dl>
    <dt>Dependencies:</dt>

    <dd>
      <ul>
        <li>Gradle 2.2.1 or higher.</li>
        <li>Build Tools 21.1.1 or higher.</li>
      </ul>
    </dd>

    <dt>General Notes:</dt>
    <dd>
    <ul>
      <li>Normalized path when creating a mockable JAR for unit testing. </li>
      <li>Fixed the <code>archivesBaseName</code> setting in the <code>build.gradle</code> file. </li>
      <li>Fixed the unresolved placeholder failure in manifest merger when building a library
      test application.</li>
    </ul>
    </dd>
  </div>
</div>



<div class="toggle-content closed">
  <p><a href="#" onclick="return toggleContent(this)">
    <img src="{@docRoot}assets/images/triangle-closed.png" class="toggle-content-img"
      alt=""/>Android Plugin for Gradle, Revision 1.1.1</a> <em>(February 2015)</em>
  </p>

  <div class="toggle-content-toggleme">

    <dl>
    <dt>Dependencies:</dt>

    <dd>
      <ul>
        <li>Gradle 2.2.1 or higher.</li>
        <li>Build Tools 21.1.1 or higher.</li>
      </ul>
    </dd>

    <dt>General Notes:</dt>
    <dd>
    <ul>
      <li>Modified build variants so only variants that package a
      <a href="{@docRoot}training/wearables/apps/index.html">Wear</a> app trigger Wear-specific
      build tasks. </li>
      <li>Changed dependency related issues to fail at build time rather than at debug time.
      This behavior allows you to run diagnostic diagnostic tasks (such as 'dependencies') to help
      resolve the conflict. </li>
      <li>Fixed the <code>android.getBootClasspath()</code> method to return a value. </li>
    </ul>
    </dd>
  </div>
</div>





<div class="toggle-content closed">
  <p><a href="#" onclick="return toggleContent(this)">
    <img src="{@docRoot}assets/images/triangle-closed.png" class="toggle-content-img"
      alt=""/>Android Plugin for Gradle, Revision 1.1.0</a> <em>(February 2015)</em>
  </p>

  <div class="toggle-content-toggleme">

    <dl>
    <dt>Dependencies:</dt>

    <dd>
      <ul>
        <li>Gradle 2.2.1 or higher.</li>
        <li>Build Tools 21.1.1 or higher.</li>
      </ul>
    </dd>

    <dt>General Notes:</dt>
    <dd>
    <ul>
      <li>Added new unit test support</li>
      <ul>
       <li>Enabled
       <a href="{@docRoot}training/activity-testing/activity-unit-testing.html">unit tests</a> to
       run on the local JVM against a special version of the <code>android.jar</code> file that is
       compatible with popular mocking frameworks, for example Mockito. </li>
       <li>Added new test tasks <code>testDebug</code>, <code>testRelease</code>, and
       <code>testMyFlavorDebug</code> when using product flavors. </li>
       <li>Added new source folders recognized as unit tests: <code>src/test/java/</code>,
       <code>src/testDebug/java/</code>, <code>src/testMyFlavor/java/</code>.
       <li>Added new configurations in the <code>build.gradle</code> file for declaring test-only
       dependencies, for example, <code>testCompile 'junit:junit:4.11'</code>,
       <code>testMyFlavorCompile 'some:library:1.0'</code>.
        <p class="note"><strong>Note:</strong> Test-only dependencies are not currently compatible
        with Jack (Java Android Compiler Kit). </p>
       </li>
       <li>Added the <code>android.testOptions.unitTests.returnDefaultValues</code> option to
       control the behaviour of the mockable android.jar. </li>
      </ul>
      <li>Replaced <code>Test</code> in test task names with <code>AndroidTest</code>.
      For example, the <code>assembleDebugTest</code> task is now
      <code>assembleDebugAndroidTest</code> task. Unit test tasks still have <code>UnitTest</code>
      in the task name, for example <code>assembleDebugUnitTest</code>. </li>
      <li>Modified <a href="{@docRoot}tools/help/proguard.html">ProGuard</a> configuration files to
      no longer apply to the test APK. If minification is enabled, ProGuard processes the test APK
      and applies only the mapping file that is generated when minifying the main APK. </li>
      <li>Updated dependency management</li>
       <ul>
       <li>Fixed issues using <code>provided</code> and <code>package</code> scopes.
         <p class="note"><strong>Note:</strong> These scopes are incompatible with AAR
         (Android ARchive) packages and will cause a build with AAR packages to fail.</p>
       </li>
       <li>Modified dependency resolution to compare the dependencies of an app under test and the
       test app. If an artifact with the same version is found for both apps, it's not included with
       the test app and is packaged only with the app under test. If an artifact with a different
       version is found for both apps, the build fails.</li>
       </ul>

      <li>Added support for <code>anyDpi</code>
      <a href="{@docRoot}guide/topics/resources/providing-resources.html"> resource qualifier</a>
      in resource merger. </li>
      <li>Improved evaluation and IDE sync speeds for projects with a large number of
      Android <a href="{@docRoot}sdk/installing/create-project.html#CreatingAModule"> modules</a>. </li>
    </ul>
    </dd>
  </div>
</div>


<div class="toggle-content closed">
  <p><a href="#" onclick="return toggleContent(this)">
    <img src="{@docRoot}assets/images/triangle-closed.png" class="toggle-content-img"
      alt=""/>Android Plugin for Gradle, Revision 1.0.1</a> <em>(January 2015)</em>
  </p>

  <div class="toggle-content-toggleme">

    <dl>
    <dt>Dependencies:</dt>

    <dd>
      <ul>
        <li>Gradle 2.2.1 up to 2.3.x.
        <p class="note"><strong>Note:</strong> This version of the Android Plugin for Gradle is
        not compatible with Gradle 2.4 and higher. </p>
        </li>
        <li>Build Tools 21.1.1 or higher.</li>
      </ul>
    </dd>

    <dt>General Notes:</dt>
    <dd>
    <ul>
      <li>Fixed issue with Gradle build failure when accessing the
      <code>extractReleaseAnnotations</code> module.
      (<a href="http://b.android.com/81638">Issue 81638</a>).</li>
      <li>Fixed issue with <code>Disable</code> passing the
      <code>--no-optimize</code> setting to the Dalvik Executable (dex) bytecode.
      (<a href="http://b.android.com/82662">Issue 82662</a>).</li>
      <li>Fixed manifest merger issues when importing libraries with a
      <code>targetSdkVersion</code> less than 16.</li>
      <li>Fixed density ordering issue when using Android Studio with JDK 8.</li>
    </ul>
    </dd>
  </div>
</div>




<div class="toggle-content closed">
  <p><a href="#" onclick="return toggleContent(this)">
    <img src="{@docRoot}assets/images/triangle-closed.png" class="toggle-content-img"
      alt=""/>Android Plugin for Gradle, Revision 1.0.0</a> <em>(December 2014)</em>
  </p>

  <div class="toggle-content-toggleme">

    <dl>
    <dt>Dependencies:</dt>

    <dd>
      <ul>
        <li>Gradle 2.2.1 up to 2.3.x.
        <p class="note"><strong>Note:</strong> This version of the Android Plugin for Gradle is
        not compatible with Gradle 2.4 and higher. </p>
        </li>
        <li>Build Tools 21.1.1 or higher.</li>
      </ul>
    </dd>

    <dt>General Notes:</dt>
    <dd>
      <ul>
        <li>Initial plugin release.</li>
      </ul>
    </dd>
  </div>
</div>




<h2>Updating the Android Plugin for Gradle Version</h2>
<p>The Android Plugin for Gradle version is specified in the
<strong>File &gt; Project Structure</strong> menu or the project-level
<code>build.gradle</code> file. The plugin version applies to all modules built in that
Android Studio project. This example updates the Android Plugin for Gradle to version 1.1.0:
<pre>
...
     dependencies {
         classpath 'com.android.tools.build:gradle:1.1.0'
     }
...
</pre>


<p class="caution"><strong>Caution:</strong> You should not use dynamic dependencies (+) in
version numbers. Using this feature can cause unexpected version updates and difficulty
resolving version differences. </p>

<p>If you're building with Gradle but using not Android Studio, the build process downloads the
latest Android Plugin for Gradle plugin when it runs. </p>



<h2>Updating the Gradle Version </h2>

<p>Android Studio requires Gradle version 2.2.1 or later. To view and
update the Gradle version, edit the Gradle distribution reference in the
<code>gradle/wrapper/gradle-wrapper.properties</code> file. This example shows the
Android Plugin for Gradle version set to 2.2.1.</p>

<pre>
...
distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1-all.zip
...
</pre>




<p>For more details about the supported Android Plugin for Gradle properties and syntax, click
the link to the
<a href="{@docRoot}tools/building/plugin-for-gradle.html">Plugin Language Reference</a>.</p>