1

I have found lots of posts about this question ,but non of them worked for me.Here is my Gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.0"

    defaultConfig {
        applicationId "*********"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 5
        versionName "1.1"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.0.0'
    compile 'com.android.support:cardview-v7:21.0.+'
    compile 'com.android.support:recyclerview-v7:21.0.+'
    compile files('libs/gradle-wrapper.jar')
    compile 'com.facebook.fresco:fresco:0.9.0+'
    compile 'com.facebook.android:audience-network-sdk:4.+'
    compile 'com.google.android.gms:play-services:7.8.0'

}

I can't figure out where there the problem is.

  • Possible duplicate of [Error: more than one library with package name 'com.google.android.gms' (v. 8.1.0)](http://stackoverflow.com/questions/32831296/error-more-than-one-library-with-package-name-com-google-android-gms-v-8-1) – Murat Karagöz Jul 11 '16 at 15:03

3 Answers3

2

You can visualize as a tree:

gradle -q dependencies yourProject:dependencies --configuration compile

Or on Windows, use gradlew

gradlew -q dependencies yourProject:dependencies --configuration compile

Example output:

compile - Classpath for compiling the main sources.
+--- org.androidannotations:androidannotations-api:3.2
+--- com.android.support:support-annotations:22.1.1
+--- com.squareup:otto:1.3.6
+--- in.srain.cube:grid-view-with-header-footer:1.0.10
+--- com.nostra13.universalimageloader:universal-image-loader:1.9.3
+--- com.github.chrisbanes.photoview:library:1.2.3
+--- org.simpleframework:simple-xml:2.7.1
+--- com.google.android.gms:play-services-base:6.5.+ -> 6.5.87
+--- project :yourProject
|    +--- com.loopj.android:android-async-http:1.4.6
|    +--- org.apache.httpcomponents:httpmime:4.2.5
|    |    \--- org.apache.httpcomponents:httpcore:4.2.4
|    \--- com.google.code.gson:gson:2.3.1
+--- project :facebook
|    \--- com.android.support:appcompat-v7:22.1.1
|         \--- com.android.support:support-v4:22.1.1
|              \--- com.android.support:support-annotations:22.1.1 -> 22.2.0

To avoid duplicates, add exclude in each project build.gradle

compile('com.github.chrisbanes.photoview:library:1.2.3') {
    exclude group: 'com.android.support'
}
compile('org.simpleframework:simple-xml:2.7.1') {
    exclude module: 'stax'
    exclude module: 'stax-api'
    exclude module: 'xpp3'
}
compile('com.google.android.gms:play-services-base:6.5.+')
        {
            exclude module: 'support-v4'
        }

This is sampled from: gradle - library duplicates in dependencies

Community
  • 1
  • 1
apelsoczi
  • 1,102
  • 8
  • 11
0

First of all you should use the same support version for your support libraries (appcompat, cardview, recyclerview) Also you can try updating fresco to the current version (0.11.0) to check if that solves the problem. Also avoid using '+' in the dependencies because it's simply a bad practice and can lead to unexpected behaviours.

Aleks Nine
  • 249
  • 7
  • 15
0

Try updating to the latest play-services library:

compile 'com.google.android.gms:play-services:9.2.0'

In any case, you should always try to only add the dependencies you will need for example:

com.google.android.gms:play-services-analytics:9.2.0
com.google.android.gms:play-services-maps:9.2.0

Check the bottom of the following link to see more about the decoupled dependencies.

Evin1_
  • 12,292
  • 9
  • 45
  • 47