如何使用 com.facebook.fresco 和 com.parse:parse-android 而不相互冲突?

How to Use com.facebook.fresco and com.parse:parse-android without confilicting each other?

我对 android 工作室的 gradle 还很陌生。我正在构建一个项目并使用 fresco 将图像加载到我的 Android 应用程序。现在我需要整合推送通知服务所以决定使用解析。但是当我尝试整合解析时,我得到了一个错误:

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: bolts/AggregateException.class

在这里搜索了一下,发现Fresco库和Parse库都使用了bolts。所以我从 Fresco 中排除了 bolts-android,现在我收到了这个错误:

Error:Execution failed for task ':app:transformClassesWithDexForDebug'. com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin/java'' finished with non-zero exit value 3

那么如何在我的 android 应用程序中同时使用 Fresco 库和 Parse 库?我的 gradle 构建文件如下:

        apply plugin: 'com.android.application'
    android {
        compileSdkVersion 23
        buildToolsVersion "23.0.2"

        defaultConfig {
            applicationId "com.osmium.ykb"
            minSdkVersion 14
            targetSdkVersion 23
            versionCode 1
            versionName "1.0"
            multiDexEnabled = true
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }

dependencies {
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:support-v4:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.android.support:cardview-v7:23.1.1'
    compile 'com.android.support:recyclerview-v7:23.1.1'
    compile 'com.loopj.android:android-async-http:1.4.9'
    compile 'com.parse.bolts:bolts-android:1.3.0'
    compile 'com.parse:parse-android:1.12.0'
    compile('com.facebook.fresco:fresco:0.8.1') {
        exclude module: 'bolts-android'
    }
    compile 'com.flaviofaria:kenburnsview:1.0.6'
    compile 'com.google.android.gms:play-services:8.4.0'
    compile 'com.android.support:multidex:1.0.0'
    compile 'com.bignerdranch.android:expandablerecyclerview:2.0.3'
}

当用'./gradlew app:dependencies'

检查时,我的依赖项是这样的
_debugApk - ## Internal use, do not manually configure #
+--- com.android.support:multidex:1.0.1
+--- com.android.support:appcompat-v7:23.1.1
|    \--- com.android.support:support-v4:23.1.1
|         \--- com.android.support:support-annotations:23.1.1
+--- com.android.support:support-v4:23.1.1 (*)
+--- com.android.support:design:23.1.1
|    +--- com.android.support:appcompat-v7:23.1.1 (*)
|    +--- com.android.support:recyclerview-v7:23.1.1
|    |    +--- com.android.support:support-annotations:23.1.1
|    |    \--- com.android.support:support-v4:23.1.1 (*)
|    \--- com.android.support:support-v4:23.1.1 (*)
+--- com.android.support:cardview-v7:23.1.1
+--- com.android.support:recyclerview-v7:23.1.1 (*)
+--- com.loopj.android:android-async-http:1.4.9
|    \--- cz.msebera.android:httpclient:4.3.6
+--- com.parse.bolts:bolts-android:1.3.0
|    +--- com.parse.bolts:bolts-tasks:1.3.0
|    \--- com.parse.bolts:bolts-applinks:1.3.0
|         \--- com.parse.bolts:bolts-tasks:1.3.0
+--- com.parse:parse-android:1.12.0
|    \--- com.parse.bolts:bolts-tasks:1.3.0
+--- com.facebook.fresco:fresco:0.8.1
|    +--- com.facebook.fresco:imagepipeline:0.8.1
|    |    +--- com.nineoldandroids:library:2.4.0
|    |    +--- com.facebook.fresco:fbcore:0.8.1
|    |    \--- com.android.support:support-v4:21.0.3 -> 23.1.1 (*)
|    +--- com.facebook.fresco:fbcore:0.8.1
|    \--- com.facebook.fresco:drawee:0.8.1
|         +--- com.facebook.fresco:fbcore:0.8.1
|         \--- com.android.support:support-v4:21.0.3 -> 23.1.1 (*)
+--- com.flaviofaria:kenburnsview:1.0.6
+--- com.google.android.gms:play-services:8.4.0
|    +--- com.google.android.gms:play-services-ads:8.4.0
|    |    \--- com.google.android.gms:play-services-basement:8.4.0
|    |         \--- com.android.support:support-v4:23.0.0 -> 23.1.1 (*)
|    +--- com.google.android.gms:play-services-analytics:8.4.0
|    |    \--- com.google.android.gms:play-services-basement:8.4.0 (*)
|    +--- com.google.android.gms:play-services-appindexing:8.4.0
|    |    \--- com.google.android.gms:play-services-base:8.4.0
|    |         \--- com.google.android.gms:play-services-basement:8.4.0 (*)
|    +--- com.google.android.gms:play-services-appinvite:8.4.0
|    |    \--- com.google.android.gms:play-services-base:8.4.0 (*)
|    +--- com.google.android.gms:play-services-appstate:8.4.0
|    |    \--- com.google.android.gms:play-services-base:8.4.0 (*)
|    +--- com.google.android.gms:play-services-auth:8.4.0
|    |    \--- com.google.android.gms:play-services-base:8.4.0 (*)
|    +--- com.google.android.gms:play-services-base:8.4.0 (*)
|    +--- com.google.android.gms:play-services-basement:8.4.0 (*)
|    +--- com.google.android.gms:play-services-cast:8.4.0
|    |    +--- com.google.android.gms:play-services-base:8.4.0 (*)
|    |    \--- com.android.support:mediarouter-v7:23.0.0
|    |         \--- com.android.support:appcompat-v7:23.0.0 -> 23.1.1 (*)
|    +--- com.google.android.gms:play-services-drive:8.4.0
|    |    \--- com.google.android.gms:play-services-base:8.4.0 (*)
|    +--- com.google.android.gms:play-services-fitness:8.4.0
|    |    +--- com.google.android.gms:play-services-base:8.4.0 (*)
|    |    \--- com.google.android.gms:play-services-location:8.4.0
|    |         +--- com.google.android.gms:play-services-base:8.4.0 (*)
|    |         \--- com.google.android.gms:play-services-maps:8.4.0
|    |              \--- com.google.android.gms:play-services-base:8.4.0 (*)
|    +--- com.google.android.gms:play-services-games:8.4.0
|    |    +--- com.google.android.gms:play-services-base:8.4.0 (*)
|    |    \--- com.google.android.gms:play-services-drive:8.4.0 (*)
|    +--- com.google.android.gms:play-services-gcm:8.4.0
|    |    +--- com.google.android.gms:play-services-base:8.4.0 (*)
|    |    \--- com.google.android.gms:play-services-measurement:8.4.0
|    |         \--- com.google.android.gms:play-services-basement:8.4.0 (*)
|    +--- com.google.android.gms:play-services-identity:8.4.0
|    |    \--- com.google.android.gms:play-services-base:8.4.0 (*)
|    +--- com.google.android.gms:play-services-location:8.4.0 (*)
|    +--- com.google.android.gms:play-services-maps:8.4.0 (*)
|    +--- com.google.android.gms:play-services-measurement:8.4.0 (*)
|    +--- com.google.android.gms:play-services-nearby:8.4.0
|    |    \--- com.google.android.gms:play-services-base:8.4.0 (*)
|    +--- com.google.android.gms:play-services-panorama:8.4.0
|    |    \--- com.google.android.gms:play-services-base:8.4.0 (*)
|    +--- com.google.android.gms:play-services-plus:8.4.0
|    |    \--- com.google.android.gms:play-services-base:8.4.0 (*)
|    +--- com.google.android.gms:play-services-safetynet:8.4.0
|    |    \--- com.google.android.gms:play-services-base:8.4.0 (*)
|    +--- com.google.android.gms:play-services-vision:8.4.0
|    |    \--- com.google.android.gms:play-services-base:8.4.0 (*)
|    +--- com.google.android.gms:play-services-wallet:8.4.0
|    |    +--- com.google.android.gms:play-services-base:8.4.0 (*)
|    |    +--- com.google.android.gms:play-services-identity:8.4.0 (*)
|    |    \--- com.google.android.gms:play-services-maps:8.4.0 (*)
|    \--- com.google.android.gms:play-services-wearable:8.4.0
|         \--- com.google.android.gms:play-services-base:8.4.0 (*)
+--- com.android.support:multidex:1.0.0 -> 1.0.1
\--- com.bignerdranch.android:expandablerecyclerview:2.0.3
     \--- com.android.support:recyclerview-v7:23.0.1 -> 23.1.1 (*) 

我已经回答了这个问题,但是找不到或者不想找到。

此处:删除此行,您就可以开始了。

compile fileTree(dir: 'libs', include: ['*.jar'])

您应该排除 bolts-taks 而不是 bolts-android,试试这个:

compile ('com.facebook.fresco:fresco:0.8.1'){
     exclude group: 'com.parse.bolts', module: 'bolts-tasks';
}

更新:

然后也许尝试从解析库中排除 bolts-android 并像这样编译整个 fresco 库:

compile ('com.parse:parse-android:1.11.0'){
     exclude group: 'com.parse.bolts', module: 'bolts-android';
}

在找到更多信息后,我找到了答案。只需添加

dexOptions {
    javaMaxHeapSize "4g"
}

对不起。我误以为这是包冲突问题。不过好像是尺寸的问题。

将它们与这些版本一起使用:

compile 'com.parse.bolts:bolts-android:1.4.0'
compile 'com.parse:parse-android:1.13.0'
compile 'com.facebook.fresco:fresco:0.9.0'