Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent Gradle dependency for support library from being overridden by newer version

In my build.gradle I have the support library as a dependency, as seen here force to revision 19.

compile 'com.android.support:support-v4:19.1.+

With revision 21 the Material Design support was introduced. I don't want to use the Material Design in this case here which is fine. The problem arises through the use of the Fabric SDK:

I include their Maven repository maven { url 'https://maven.fabric.io/repo' } and compile the Twitter dependencies:

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

compile('com.twitter.sdk.android:twitter-core:1.0.0@aar') {
    transitive = true;
}

Now what happens is that I get the support library in revision 21. What happened here? Does the Fabric SDK use the neweset support library?

How can I force it to revision 19 anyway?

like image 430
Mahoni Avatar asked Nov 13 '14 19:11

Mahoni


People also ask

How do you avoid transitive dependencies in Gradle?

When you specify a dependency in your build script, you can provide an exclude rule at the same time telling Gradle not to pull in the specified transitive dependency. For example, say we have a Gradle project that depends on Google's Guava library, or more specifically com.

How do I know if Gradle dependency has new version?

Go to Android Studio -> Preferences -> Plugins (for Mac) and File -> Settings -> Plugins (for windows) and search “Check for Dependency updates plugin”. Install it and restart android studio. You will be able to see Dependencies tab on the right which will show if any dependency has a new update available.


1 Answers

Feel free to exclude the Android Support Library and provide your own version.

compile('com.twitter.sdk.android:twitter:1.0.0@aar') { 
       transitive = true; 
       exclude module: 'support-v4' 
}

Make sure you provide your own version though, otherwise you'll get runtime errors

like image 87
tsmith Avatar answered Sep 30 '22 01:09

tsmith