android - app:transformDexArchiveWithExternalLibsDexMergerForDebug:无法合并Dex Android Studio 3.0.1

标签 android gradle android-gradle-plugin

我几乎尝试了所有解决方案,但是我认为这是我的项目库特有的。

这是我的项目级别。

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
}

这是我的应用程序级别
apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion '27.0.2'

    defaultConfig {
        applicationId "com.codepath.the_town_kitchen"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    signingConfigs {
        debug {
            storeFile file("keystore/debug.keystore")
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories { mavenCentral() }

repositories {
    mavenCentral()
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')

    compile 'com.android.support:cardview-v7:27.0.2'
    compile 'com.android.support:appcompat-v7:27.0.2'
    compile 'com.android.support:recyclerview-v7:27.0.2'

    compile 'com.squareup.picasso:picasso:2.4.0'
    compile 'com.loopj.android:android-async-http:1.4.6'
    compile 'com.google.android.gms:play-services:6.5.87'
    compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
    compile 'com.facebook.android:facebook-android-sdk:3.21.1'
    compile 'com.github.flavienlaurent.datetimepicker:library:0.0.2'
    compile 'com.parse.bolts:bolts-android:1.+'
    compile 'com.github.johnkil.android-robototextview:robototextview:2.3.0'
    compile fileTree(dir: 'libs', include: 'Parse-*.jar')
    compile 'com.makeramen:roundedimageview:1.5.0'
    compile 'com.stripe:stripe-android:2.0.2'
}

我试图将所有库与最新版本同步,还添加了multiDexEnabled选项。但是,它仍然无法正常工作。我还可以修改些什么来跟踪问题?

我正在使用Stripe作为支付网关。我试图弄清楚它的库是否有问题,但是我没有发现是相对的。

最佳答案

我不太确定该解决方案。但是,我认为您正在使用的外部库中具有不同的支持库版本。您需要定义在应用程序中使用的支持库的确切版本。所以我认为您需要像下面那样修改build.gradle

删除repositories { mavenCentral() },因为已经在另一个地方定义了它。

并在您的应用程序级别build.gradle中添加以下配置。

configurations.all {
    resolutionStrategy {
        force 'com.android.support:design:27.0.2'
        force 'com.android.support:support-v4:27.0.2'
        force 'com.android.support:appcompat-v7:27.0.2'
    }
}

关于android - app:transformDexArchiveWithExternalLibsDexMergerForDebug:无法合并Dex Android Studio 3.0.1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49091936/

相关文章:

android - 配置特定的 gradle flavor 组合

java - 尝试获取当前用户信息时出错

java - 如何获取 FragmentPagerAdapter 中的当前位置?

java - 我想让 ViewPager 到达第 4 页时可见按钮,但出现空指针异常

android - Gradle 没有在 gradle.bat 中设置 javahome

android - Gradle 4.9 + Lombok 1.18.0 失败

android - 有人可以解释 descendantFocusability = afterDescendants 吗?

gradle - 带有 Gradle 应用程序插件的 Kotlin 应用程序

gradle - gradle是否在版本中支持逗号以指定多个范围?

unit-testing - 在 IntelliJ 中运行单元和集成测试