Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gradle dependency error in android

In the following build.gradle, I added the configuration section to avoid double inclusion of support libraries. Support libraries are used in the main project and in the dependent projects like facebook sdk. Without the configuration section, I get "UNEXPECTED TOP-LEVEL EXCEPTION". Adding that configuration makes the error go away and the app all works fine.

Now, I'm trying to add RecyclerView to my app and I get RecyclerView class not found while inflating the recyclerview (although it builds ok). If I remove the facebook SDK and configuration section, the recyclerview works just fine.

Question: What changes can I make to the build.gradle to make the facebook SDK work and RecyclerView work? In other words, why is the config section excluding v7 when it is only supposed to exclude v4?


dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:support-v4:+'
    compile 'com.android.support:support-v13:+'
    compile 'com.android.support:cardview-v7:+'
    compile 'com.android.support:recyclerview-v7:+'
    compile 'com.google.android.gms:play-services:4.4.52'
    compile project(':facebook-3.15')
    compile project(':parse-1.5.1')
    compile project(':viewpagerindicator-2.4.1')
}

configurations {
    // to avoid double inclusion of support libraries
    all*.exclude group: 'com.android.support', module: 'support-v4'
}
like image 912
nomongo Avatar asked Aug 25 '14 14:08

nomongo


People also ask

How do I resolve Gradle dependencies?

Given a required dependency, with a version, Gradle attempts to resolve the dependency by searching for the module the dependency points at. Each repository is inspected in order. Depending on the type of repository, Gradle looks for metadata files describing the module ( .

What is a Gradle dependency?

Last Updated on April 3, 2022. In Gradle dependencies are libraries required to build your code. Each of these libraries may have their own dependencies, adding transitive dependencies to your project. This structure is called the Gradle dependency tree, with its own rules on dependency conflict resolution and more.

Where are Gradle settings on Android?

Settings file 'C:\code\project\android\settings. gradle' line: 3 #159.


1 Answers

If you're having a dependency conflict with the v4 support library, you can just exclude it from one of the libraries via the gradle script:

compile ('com.android.support:recyclerview-v7:+') {
    exclude module: 'support-v4'
}
like image 53
Kevin Coppock Avatar answered Oct 17 '22 05:10

Kevin Coppock