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
但是我不知道怎么排除这个错?
请大神指点一二!
...全文
1343 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
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 这个应该是告诉你有包冲突了. 具体是哪个包冲突了, 你需要仔细看错误提示.

80,472

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧