android ui依赖中添加脑树拖放时,dex文件无法合并

时间:2018-09-12 08:39:52

标签: android paypal braintree

朋友,我正在开发一个具有付款选项的android应用程序。我希望与PayPal集成,因此我将Braintree直接方法与Brain Tree SDK支持一起使用,但是当我添加UI依赖项的下降时,它会显示错误。

Error:Execution failed for 
 task:app:transformDexArchiveWithExternalLibsDexMergerForDebug.
    > java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

我在下面附加了gradle文件

dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'com.android.support:appcompat-v7:27.1.1'
        implementation 'com.android.support.constraint:constraint-layout:1.1.3'
        testImplementation 'junit:junit:4.12'
        implementation 'com.braintreepayments.api:braintree:2.+'
        implementation 'com.braintreepayments.api:drop-in:3.0.0'
    }

build.gradle文件

 apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        multiDexEnabled true
        applicationId "com.stunntech.paypalandroid"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    implementation 'com.braintreepayments.api:braintree:2.4.0'
   // implementation 'com.braintreepayments.api:drop-in:3.0.5'
}

2 个答案:

答案 0 :(得分:1)

查看关于此问题的答案,据我了解您存在相同的问题:

Unable to merge dex

希望它对您有帮助

启用MultiDex:

android {

    defaultConfig {

        // Enabling multidex support.
        multiDexEnabled true
    }

    dexOptions {
        jumboMode true
    }
}
dependencies {
implementation 'com.android.support:multidex:1.0.3'
}

答案 1 :(得分:0)

只需使用

defaultConfig
            {

                multiDexEnabled true

            }'

在您的gradle文件中