android - .DexArchiveMergerException:无法合并 dex
问题描述
通过android studio开发android系统应用环境。
将/target/common/obj/JAVA_LIBRARIES/framework_intermediates/classes.jar复制到app/libs。重命名framework.jar
添加
provided fileTree(dir: 'libs', include: ['*.jar'])
到build.gradle添加
options.compilerArgs << '-Xbootclasspath/p:app\\libs\\framework.jar'
重建项目时,发生错误
Error:Execution failed for task
':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: java.lang.RuntimeException:
com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.systemapplication"
minSdkVersion 26
targetSdkVersion 26
multidexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
cppFlags ""
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
provided fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-
core:3.0.2'
}
Error:(6, 1) A problem occurred evaluating project ':app'.
> Could not find method multidexEnabled() for arguments [true] on
DefaultConfig_Decorated{name=main,
解决方案
此错误app:transformDexArchiveWithExternalLibsDexMergerForDebug
通常是由于添加了可能与您的compileSdkVerison
.
在您的项目中启用 Multidex。要启用它打开build.gradle(Module:app)
文件,然后在defaultConfig
块中写入multidexEnabled true。
现在,清理并重建您的项目。
推荐阅读
- java - 如何尽可能准确地画出蝴蝶曲线?
- java - JCIFS SmbFile RenameTo 无法移动文件
- c++ - 迷失在哪本书/指导 C++ 的进步
- sql-server - 从字符串值中删除 1 个字母
- javascript - 从 index.ts 访问变量到组件
- bash - Bash:如何在按下特定键时停止循环,例如 Q?
- laravel - 搜索框count():参数必须是数组或者实现了Countable的对象
- android - WearOS 打包:程序类型已经存在:
.BuildConfig - javascript - 如何扩展或合并样式化组件主题
- r - 数据表中的多个javascript