在gradle中添加新的facebook lib后出现依赖性错误

时间:2015-01-25 23:42:26

标签: android android-gradle android-facebook

在我的项目依赖项中添加compile 'com.facebook.android:facebook-android-sdk:3.21.1'之后,当我尝试构建并运行应用程序时,我开始收到此错误(按下android工作室中的播放按钮): 输出:

Error:Execution failed for task ':dexDebug'.
......
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompatIcs;
    at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:594)
    at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:552)
    at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:533)
    at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170)
    at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
    at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
    at com.android.dx.command.dexer.Main.run(Main.java:230)
    at com.android.dx.command.dexer.Main.main(Main.java:199)
    at com.android.dx.command.Main.main(Main.java:103)

这是我完整的gradle构建文件:

buildscript {
    repositories {
        mavenCentral()
        maven { url 'http://repo1.maven.org/maven2' }
        maven { url 'http://download.crashlytics.com/maven' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.0.0'
        classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'

    }
}
apply plugin: "eclipse"
apply plugin: 'com.android.application'
apply plugin: 'crashlytics'
repositories {
    mavenCentral()
    maven { url 'http://repo1.maven.org/maven2' }
    maven { url 'http://download.crashlytics.com/maven' }
}
android {

    compileSdkVersion 19
    buildToolsVersion "19.1.0"

    dependencies {
        compile fileTree(dir: 'libs', include: '*.jar')
        compile project(":libraries:dialog-manager-lib")
        compile project(":libraries:google-play-services-lib")
        compile project(":libraries:pager-indicator-lib")
        compile project(":libraries:apphance-library-1.9.11")
        compile 'com.crashlytics.android:crashlytics:1.+'
    }

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 19
//        multiDexEnabled true
        testInstrumentationRunner "android.test.InstrumentationTestRunner"
    }

    signingConfigs {
        release {
            storeFile file(RELEASE_KEYSTORE_FILE)
            storePassword System.getenv("PASSWORD_KEYSTORE_JB")
            keyAlias System.getenv("ALIAS_KEYSTORE_JB")
            keyPassword System.getenv("PASSWORD_KEYSTORE_JB")
        }

        debug {
            storeFile file(DEBUG_KEYSTORE_FILE_LOCAL)
        }

        beta {
            storeFile file(DEBUG_KEYSTORE_FILE_LOCAL)
        }

    }

    buildTypes {
        debug {
            debuggable true
            signingConfig android.signingConfigs.debug
            applicationIdSuffix ".debug"
        }
        release {
            signingConfig signingConfigs.release
        }

        beta {
            debuggable true
            signingConfig android.signingConfigs.debug
            applicationIdSuffix ".beta"
        }
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        release {
            res.srcDirs = ['res_release']
        }

        beta {
            res.srcDirs = ['res_beta']
        }

        instrumentTest.setRoot('test')
        instrumentTest {
            java.srcDirs = ['test']
        }
    }

    lintOptions {
        abortOnError false
    }
}
task wrapper(type: Wrapper) {
    gradleVersion = '1.11'
}
dependencies {
    compile 'com.mixpanel.android:mixpanel-android:4.5.2'
    compile 'com.facebook.android:facebook-android-sdk:3.21.1'
//    compile 'com.android.support:multidex:1.0.0'
}
//allprojects {
//    repositories {
//        jcenter()
//    }
//    configurations.all((Closure) {
//        resolutionStrategy {
//            force 'com.android.support:support-v4:21.0.3' // your version of support library
//        }
//    })
//
//} 

在我通过下载localy并在gradle文档的andeoid.dependeces部分中引用它之前使用facebook库之前,这非常有用。有关如何解决问题的任何建议。这里也是依赖树:

 _betaCompile - ## Internal use, do not manually configure ##
+--- project :libraries:dialog-manager-lib
|    \--- com.android.support:support-v4:21.0.3
|         \--- com.android.support:support-annotations:21.0.3
+--- project :libraries:google-play-services-lib
+--- project :libraries:pager-indicator-lib
|    \--- com.android.support:support-v4:21.0.3 (*)
+--- project :libraries:apphance-library-1.9.11
|    \--- com.android.support:support-v4:21.0.3 (*)
+--- com.crashlytics.android:crashlytics:1.+ -> 1.1.13
+--- com.mixpanel.android:mixpanel-android:4.5.2
+--- com.facebook.android:facebook-android-sdk:3.21.1
|    +--- com.parse.bolts:bolts-android:1.1.2
|    \--- com.android.support:support-v4:[20,21) -> 21.0.3 (*)
\--- com.android.support:multidex:1.0.0

感谢。

0 个答案:

没有答案