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
但是我不知道怎么排除这个错?
请大神指点一二!
...全文
1438 3 打赏 收藏 转发到动态 举报
写回复
用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 这个应该是告诉你有包冲突了. 具体是哪个包冲突了, 你需要仔细看错误提示.
内容概要:本文围绕“基于交流潮流的电力系统多元件N-k故障模型研究”展开,深入探讨了利用Matlab代码实现电力系统在发生多个关键元件同时故障(即N-k故障)情况下的交流潮流计算与故障分析方法。该模型不仅考虑了传统潮流方程的非线性特性,还引入了故障约束条件,能够精确模拟复杂多样的故障场景,如短路、断线等,进而评估电网在极端运行条件下的稳态与动态行为。研究通过构建典型电力系统算例,验证了所提模型在故障筛选、脆弱性识别及系统恢复策略制定方面的有效性,为电力系统安全评估、风险预警和防御体系构建提供了坚实的理论依据和技术支撑。此外,模型具备良好的扩展性,可进一步应用于连锁故障传播分析、恶意攻击模拟等高级安全分析领域。; 适合人群:具备电力系统分析基础理论知识和Matlab编程能力的高校研究生、科研院所研究人员以及电力公司从事电网规划、运行与安全管理的技术人员,特别适用于开展电力系统安全稳定、可靠性评估与应急响应机制研究的专业人士。; 使用场景及目标:①开展电力系统在多重故障条件下的交流潮流仿真,评估系统电压稳定性、线路过载风险及负荷损失程度;②识别电网中的关键薄弱环节与脆弱元件,支撑电网加固改造与防御资源配置;③用于科研项目中的故障场景建模与算法验证,或作为教学案例帮助学生理解复杂故障下的系统响应机制。; 阅读建议:此资源以Matlab代码为核心实现手段,建议读者结合理论推导与代码实现进行对照学习,重点关注故障建模过程中雅可比矩阵的修正方法、故障注入方式及收敛性处理策略,建议在仿真中逐步增加故障数量与复杂度,深入理解N-k故障对系统潮流分布的影响规律,并尝试将其拓展至含新能源接入的现代电力系统场景中进行验证与优化。

80,488

社区成员

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

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