Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Why should (or shouldnt) I include a gradle dependency as @aar,

What are the benefits/drawbacks if any?

As you can see I added @aar to the libraries below that supported it. But everything seemed to work before doing that as well...

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.1.1'
    compile 'com.google.android.gms:play-services-maps:7.3.+'
    compile 'com.google.guava:guava:18.0'
    compile 'com.octo.android.robospice:robospice-spring-android:1.4.14'
    compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.13'
    compile 'com.mcxiaoke.volley:library-aar:1.0.0@aar'
    compile 'de.psdev.licensesdialog:licensesdialog:1.7.0@aar'
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
282 views
Welcome To Ask or Share your Answers For Others

1 Answer

Libraries can be uploaded in multiple formats, most of the time you'll be using .jar or .aar.

When you don't specify the @ suffix, you'll be downloading the library in it's default format (defined by its author, if not then .jar) along with all its dependencies.

compile 'com.android.support:appcompat-v7:22.1.1'

When you specify the @ suffix you enforce downloading the library in the format you specify (which may or may not exist). This is useful e.g. when author forgot to specify that the library is an .aar and maven (or gradle, not sure) treats it as .jar by default. When the @ suffix is specified the dependencies of this library are no longer downloaded so you have to ensure that manually.

compile 'com.android.support:appcompat-v7:22.1.1@aar'
compile 'com.android.support:support-v4:22.1.1@jar'

To ensure the full dependency tree of the library is downloaded while the @ suffix is specified you have to write it in the following way:

compile ('com.android.support:appcompat-v7:22.1.1@aar') {
    transitive = true
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...