导航
  • 主页
  • 音视频
  • Camera
  • UI
  • 协议
  • SDK
  • NDK
  • Flutter
  • ADB
  • Android Studio
  • 模拟器
  • 问答

java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerExcep 错误

youyiyang 阳狮集团 2018-03-20 10:45:11
你好!
我在使用github上的一个开源项目, Android-Debug-Database的时候build报错 :
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

这个项目主要是不用root就能在网页上调试sqllite数据库。
我的这个APP的gradle在下面:
project的 build.gradle:

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

buildscript {
repositories {
jcenter()
}
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' }
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}



app的build.gradle:

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "27.0.0"

defaultConfig {
applicationId "com.example.eddieyou.iceboxmanager"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"

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

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

}

dependencies {

compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
implementation project(':debug-db')
debugImplementation 'com.amitshekhar.android:debug-db:1.0.3'
}



debug-db的build.gradle:

/*
*
* * Copyright (C) 2016 Amit Shekhar
* * Copyright (C) 2011 Android Open Source Project
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*/

apply plugin: 'com.android.library'

android {
compileSdkVersion 27
buildToolsVersion '26.0.2'

defaultConfig {
minSdkVersion 14
targetSdkVersion 27
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

resValue("string", "PORT_NUMBER", "8080")
}

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

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

}

}

dependencies {

compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
compile 'com.google.code.gson:gson:2.8.0'
compile 'net.zetetic:android-database-sqlcipher:3.5.7@aar'
compile 'android.arch.persistence.room:runtime:1.0.0'
}

//apply from: 'debug-db-upload.com'

请问上面哪里写的不对?
另外,我 参考了这篇博文,它也提到这个错误:
http://blog.csdn.net/o279642707/article/details/68946230
但是我不知道怎么排除这个错?
请大神指点一二!
...全文
691 点赞 收藏 3
写回复
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
youyiyang 2018-03-21
问题找到了,是Android Support v4,v7包冲突问题。我首先加了"multiDexEnabled true"在defaultConfig 里面,然后就报错提示这个冲突问题。然后改成 “compile ('com.android.support:appcompat-v7:23.4.0'){ exclude module: 'support-v4' }” 就build通过了。 下面把我改好的3个build.gradle都发布一下吧: project的build.gradle:

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

buildscript {
    repositories {
        jcenter()
    }
    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' }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

app的build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.0"

    defaultConfig {
        applicationId "com.example.eddieyou.iceboxmanager"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

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

dependencies {
    //compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile ('com.android.support:appcompat-v7:23.4.0'){
        exclude module: 'support-v4'
    }

    implementation project(':debug-db')
}

module的build.gradle:

/*
 *
 *  *    Copyright (C) 2016 Amit Shekhar
 *  *    Copyright (C) 2011 Android Open Source Project
 *  *
 *  *    Licensed under the Apache License, Version 2.0 (the "License");
 *  *    you may not use this file except in compliance with the License.
 *  *    You may obtain a copy of the License at
 *  *
 *  *        http://www.apache.org/licenses/LICENSE-2.0
 *  *
 *  *    Unless required by applicable law or agreed to in writing, software
 *  *    distributed under the License is distributed on an "AS IS" BASIS,
 *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  *    See the License for the specific language governing permissions and
 *  *    limitations under the License.
 *
 */

apply plugin: 'com.android.library'

android {
    compileSdkVersion 27
    //buildToolsVersion '25.0.3'

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

        resValue("string", "PORT_NUMBER", "8080")
        multiDexEnabled true
    }

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

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

    }
}

dependencies {
    //compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    testCompile 'junit:junit:4.12'
    compile 'com.google.code.gson:gson:2.8.0'
    compile 'net.zetetic:android-database-sqlcipher:3.5.7@aar'
    compile "android.arch.persistence.room:runtime:1.0.0"
}

//apply from: 'debug-db-upload.gradle'
回复
jklwan 2018-03-20
你的module和library的build.gradle中的版本要保持一致,如果基于27则全用27的版本,不能一个27,一个23,一个26;

compileSdkVersion 27
    buildToolsVersion "27.0.0"
 
    defaultConfig {

        minSdkVersion 14
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
 
    }
.........
compile 'com.android.support:appcompat-v7:27.1.0'
......
debug-db的build.gradle也按照这个改
回复
xiaohuh421 2018-03-20
Unable to merge dex 这个应该是告诉你有包冲突了. 具体是哪个包冲突了, 你需要仔细看错误提示.
回复
发动态
发帖子
Android
创建于2009-10-09

7.8w+

社区成员

移动平台 Android
申请成为版主
社区公告
暂无公告