1

In my gradle build script, i have the following

dependencies {
    compile 'foo.bar:beef:1.2.3@aar'
}
  1. What is the suffix aar for?
  2. What is the difference between using compile 'foo.bar:beef:1.2.3@aar' vs compile 'foo.bar:beef:1.2.3'
Weizhi
  • 1,027
  • 8
  • 22

2 Answers2

2

From the documentation

The @ character separates the dependency’s coordinates from the artifact’s file extension.

So this:

dependencies {
    compile 'foo.bar:beef:1.2.3@aar'
}

is equivalent to this:

dependencies {
    compile(group: 'foo.bar', name: 'beef', version: '1.2.3', extension: 'aar')
}

The default extension is '.jar' if not specified.

Nick Rundle
  • 579
  • 3
  • 8
  • Is there a way to tell from the dependency syntax whether the lib is expected to be in an artifact repo somewhere or locally e.g. located in /libs? Or maybe anything without a fileTree function will have to be in a repo? – CCJ Apr 15 '21 at 00:29
0

Please check the following link :

Why should I include a gradle dependency as `@aar`

Here you can note that in gradle, it is denoted as "aar", where as in other java development frameworks, it is denoted as ".jar". So this suffix "aar" is nothing but an archive.

The main difference between a Jar and a AAR is that AARs include resources such as layouts, drawables etc. This makes it a lot easier to create self-contained visual components. For example if you have multiple apps that use the same login screen, with Jars you could share classes but not the layout, styles, etc., you still had to duplicate them. With AARs everything is bundled in one neat package.

Arahan Jha
  • 13
  • 1
  • 8