【问题标题】:dex file unable to merge when adding brain tree drop in ui dependency in android在android中的ui依赖中添加brain tree drop时dex文件无法合并
【发布时间】:2019-02-16 20:17:38
【问题描述】:

朋友们,我正在开发一个有支付选项的安卓应用程序。我想要 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'
}

【问题讨论】:

    标签: android paypal braintree


    【解决方案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'
    }
    

    【讨论】:

    • 我只有在添加 UI 依赖项时才收到错误。我尝试了所有上述建议的方法。
    • 你能发布你的 build.gradle 文件吗?
    • 我把它和我的问题一起添加
    • 看起来您没有启用 multiDex 模式,并且您添加的依赖项有很多引用,因此您需要启用 MultiDex:再次检查我的回复,我将对其进行更新。跨度>
    【解决方案2】:

    只需使用

    defaultConfig
                {
    
                    multiDexEnabled true
    
                }'
    

    在你的 gradle 文件中

    【讨论】:

      猜你喜欢
      • 2018-08-24
      • 2018-08-29
      • 2015-02-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-26
      • 1970-01-01
      相关资源
      最近更新 更多