Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
340 views
in Technique[技术] by (71.8m points)

java - What does transitive = true in Gradle exactly do (w.r.t. crashlytics)?

What does Gradle transitive = true do exactly? It is not clear from the Gradle documentation. This is in the context of compile within build.gradle. In my case I'm depending Android's crashlytics.

compile('com.crashlytics.sdk.android:crashlytics:2.2.2@aar') {
    transitive = true;
}

Several Gradle docs (here and here) imply that "transitive" defaults to true. Yet removing transitive = true results in transitive dependencies not being brought in (in particular KitGroup).

class file for io.fabric.sdk.android.KitGroup not found

The docs say it defaults to true, yet the actual behavior seems to be the opposite.

I am running Gradle 2.2.1. Perhaps the behavior changed between 2.2 and 2.4?

Edit: Related Transitive dependencies not resolved for aar library using gradle

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

You are using the @aar notation.
It means that you want to download only the aar artifact, and no transitive dependencies.

You can check Dependency management in Gradle in the official documentation. In particular:

An artifact only notation creates a module dependency which downloads only the artifact file with the specified extension. Existing module descriptors are ignored.

Using the @aar notation if you want to download the dependencies, you should add transitive=true.

I'd expect that omitting @aar it should work without adding the transitive attribute.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...