What does transitive = true in Gradle exactly do (w.r.t. crashlytics)?
Solution 1
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.
Solution 2
On a more general note:
Setting transitive = false
on the crashlytics
library causes gradle to ignore all libraries required by crashlytics
(="transient libraries") and not download and link them.
You would have to either manually add the required libraries to your project or rely on other transient libraries added by other dependencies.
Default for gradle is transitive = true
.
Examples and full explanation here: http://www.devsbedevin.net/android-understanding-gradle-dependencies-and-resolving-conflicts/
Solution 3
My guess is that the Crashlytics artifact to which you're referring manually specifies dependencies as not transitive (transitive=false
) so that you aren't forced to bring those dependencies in by default. That's why you're seeing the opposite behavior. For example some developers may not want to pull in all of Google Play Services or whatever else Crashlytics may use if present.
So, by removing that, Gradle no longer pulls in the dependency, and it fails to build. You can specify that dependency manually if you need to.
That being said - I think the bigger issue at hand is that you shouldn't be referencing the Crashlytics artifact directly - you should be using Fabric, and pulling in Crashlytics as a result: https://dev.twitter.com/fabric/android/integrating
Solution 4
Sets whether this dependency should be resolved including or excluding its transitive dependencies. The artifacts belonging to this dependency might themselve have dependencies on other artifacts. The latter are called transitive dependencies.
Solution 5
Gradle follows transitive dependencies by default. If you want to turn that off for a particular library, use the transitive flag.
Changing the value of the transitive flag to false prevents the download of transitive dependencies, so you’ll have to add whatever is required yourself. If you only want a module jar, without any additional dependencies, you can specify that as well.
Related videos on Youtube
Steve Kuo
Software, pilot, travel, life http://www.linkedin.com/in/stevekuo1
Updated on April 15, 2021Comments
-
Steve Kuo about 3 years
What does Gradle
transitive = true
do exactly? It is not clear from the Gradle documentation. This is in the context ofcompile
withinbuild.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 particularKitGroup
).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
-
dnault almost 9 yearswhen defining configurations, or when defining dependencies?
-
Konrad almost 9 yearsDependencies of jar files are promoted to sub projects. Not every project need to define it's dependencies explicitly.
-
Oleg Estekhin almost 9 yearsWhat exactly is not clear in this documentation?
-
Steve Kuo almost 9 years@OlegEstekhin the documentation doesn't match the runtime behavior I'm seeing
-
-
Mark McClelland about 8 yearsThe instructions for migrating to Fabric specify referencing the Crashlytics artifact directly, presuming you are using that Fabric "kit": fabric.io/migrations/gradle
-
Mark McClelland about 8 yearsIt looks like the intention is that you reference the kits directly, and they pull in the io.fabric.sdk.android classes via transitive dependency.
-
Mark McClelland about 8 yearsI confirmed that omitting @aar and removing the transitive attribute works. The intention here is that developers reference the Fabric kits explicitly (e.g., "compile 'com.crashlytics.sdk.android:crashlytics:2.5.5'"), and that the core io.fabric.sdk.android classes be pulled in via transitive dependency. If you set transitive=false, then the io.fabric.sdk.android.Fabric class will not be found at compile time.
-
w3bshark about 8 yearsI think it's fair that you pointed out a bug. But, your description of the property isn't helpful. "transitive controls transitivity. Gradle normally defaults to transitive, except when it doesn't." Really, dude?... Really?
-
Navin about 8 years@w3bshark I thought it was funny. "defaults to transitive, except when it doesn't" is pretty accurate in my experience.
-
hrbrmstr over 7 yearsWhat value did this add beyond the advice in the highly upvoted answer?
-
dowi about 7 yearsthis "feature" is so bad, i want an aar with its dependencies. without the @aar it searches for jar and complains
-
Morozov almost 5 yearslink doesn't work. I'm afraid it is not by default true, because in some cases specifically write true
-
android developer about 3 yearsWhat's the point of it, then? Why not avoid using "@aar" and "transitive=true" together?
-
android developer over 2 yearsSo if it's turned on by default, why do various SDK-tutorials say to add it as true?