添加谷歌分析时,在Android工作室中Gradle构建失败

时间:2016-03-17 10:30:30

标签: android android-studio google-analytics build.gradle

您好我是Android工作室的新手,并且正在我的项目中添加谷歌分析我正在从谷歌分析官方网站试用一个示例项目,该演示工作正常,但当我从我的项目添加代码时,它说下面的错误,

错误

Error:Execution failed for task ':Stush:processDebugResources'.
> Error: more than one library with package name 'com.google.android.gms'
  You can temporarily disable this error with android.enforceUniquePackageName=false
  However, this is temporary and will be enforced in 1.0

这是我的gradle.build文件

buildscript {
    repositories {
        mavenCentral()
        jcenter()
        mavenLocal()
        maven {
            name 'maven.aviary.com'
            url uri("http://maven.aviary.com/repo/release")
        }
        maven { url 'https://maven.fabric.io/public' }

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
        classpath 'io.fabric.tools:gradle:1.+'
    }
}



apply plugin: 'android'
apply plugin: 'io.fabric'



android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.company.stush"
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}


repositories {
    mavenCentral()
    jcenter()
    mavenLocal()
    maven {
        name 'maven.aviary.com'
        url uri("http://maven.aviary.com/repo/release")
    }
    maven { url 'https://maven.fabric.io/public' }
}


dependencies {
    // compile fileTree(dir: 'libs', include: '*.jar')
    //compile 'com.android.support:support-v4:23.0.0'
    compile 'com.soundcloud.android:android-crop:1.0.0@aar'
    compile 'com.aviary.android.feather.sdk:aviary-sdk:3.6.5'
    compile 'com.facebook.android:facebook-android-sdk:4.1.0'

    compile files('picasso-2.5.2.jar')
    compile files('ion-2.1.6.jar')
    compile files('libs/urlimageviewhelper-1.0.4.jar')
    // compile files('libs/android-support-v7-appcompat.jar')
    compile files('androidasync-2.1.6.jar')
    compile files('libs/http_client/commons-codec-1.6.jar')
    compile files('libs/http_client/commons-logging-1.1.3.jar')
    compile files('libs/http_client/fluent-hc-4.3.2.jar')
    compile files('libs/http_client/httpclient-4.3.2.jar')
    compile files('libs/http_client/httpclient-cache-4.3.2.jar')
    compile files('libs/http_client/httpcore-4.3.1.jar')
    compile files('libs/http_client/httpmime-4.3.2.jar')
    compile project(':google-play-services_libs')
    compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
        transitive = true;
    }

    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.android.gms:play-services:7.3.0'
    compile 'com.android.support:appcompat-v7:22.0.0'

}



android {
    compileSdkVersion 21
    buildToolsVersion "20.0.0"


    lintOptions {
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }


    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/LGPL2.1'
    }
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }
    dexOptions {
    }
}

请帮我救我。谢谢大家

1 个答案:

答案 0 :(得分:0)

查看错误,您已包含多个包含com.google.android.gms包名称的库。可能是它的 compile project(':google-play-services_libs')

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

你应该删除其中一个。