【问题标题】:Getting dex merge issue when build the gradle in android studio 3.0 [duplicate]在android studio 3.0中构建gradle时出现dex合并问题[重复]
【发布时间】:2017-11-06 09:07:45
【问题描述】:

我无法构建 gradle 并出现错误。我使用的是 android studio 3.0 稳定版

错误:任务 ':app:transformDexArchiveWithExternalLibsDexMergerForDebug' 执行失败。 com.android.builder.dexing.DexArchiveMergerException: 无法合并 dex

详情:

Information:Gradle tasks [clean, :app:assembleDebug]
Error:Execution failed for task   
':app:transformClassesWithMultidexlistForDebug'.
> java.io.IOException: Can't write [D:\Studio Projects\SampleMVP 
\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can't   read [D:\Studio Projects\SampleMVP\app\build\intermediates\transforms\desugar\debug\13.jar(;;;;;;**.class)] (Duplicate zip entry [13.jar:android/support/v4/view/ViewPager$1.class]))
Information:BUILD FAILED in 4m 6s
Information:1 error
Information:0 warnings
Information:See complete output in console

我的app gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 27
buildToolsVersion "27.0.0"
defaultConfig {
    applicationId "ocs.com.samplemvp"
    minSdkVersion 15
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
    multiDexEnabled true
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 
'proguard-rules.pro'
    }
}
dataBinding {
    enabled = true
}


compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:27.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}

我尝试了很多次清理和重建但没有工作

【问题讨论】:

标签: android android-gradle-plugin build.gradle gradle-plugin android-studio-3.0


【解决方案1】:

1.如果你不能从 android studio 菜单中重建你的项目 Invalidate caches/restrat...

2.清理您的项目,然后重新构建它。

3. 删除/project目录中的/build目录,并从/project/app/目录中删除/build目录,然后重新制作项目。

5. 从 android studio 菜单 Invalidate caches/restrat... 4.如果您已经安装了应用程序,请将其卸载。

Unable to merge dex可以帮你

【讨论】:

  • 当我将支持库版本 26.1.027.0.0 降级时,我的问题已得到解决,谢谢大家
  • 这些步骤你做过了吗?
  • 是的,降级后我跟着它
【解决方案2】:

1.重建您的项目

2.清理您的项目,然后重新构建它。

3. 删除/project目录下的/build目录和/project/app/目录下的/build目录,然后重新制作项目。

4.如果您已经安装了应用程序,请将其卸载。

【讨论】:

  • 我无法重建应用程序
猜你喜欢
  • 2018-04-24
  • 1970-01-01
  • 1970-01-01
  • 2018-04-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-27
  • 2019-01-08
相关资源
最近更新 更多