반응형
java.lang.RuntimeException : com.android.builder.dexing.DexArchiveMergerException : Android Studio 3.0에서 dex를 병합 할 수 없습니다.
이것은 내 앱 수준 gradle 파일입니다.
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '27.0.0'
useLibrary 'org.apache.http.legacy'
defaultConfig {
multiDexEnabled true
applicationId 'com.example.test'
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
productFlavors {
}
dexOptions {
incremental true
}
}
dependencies {
compile 'com.google.android.gms:play-services:10.0.1'
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
compile 'commons-io:commons-io:1.3.2'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.facebook.stetho:stetho:1.5.0'
compile 'com.github.PhilJay:MPAndroidChart:v3.0.2'
}
프로젝트를 컴파일 할 때 발생하는 전체 오류는 다음과 같습니다.
오류 : ': app : transformDexArchiveWithExternalLibsDexMergerForDebug'작업에 대한 실행이 실패했습니다.
java.lang.RuntimeException : com.android.builder.dexing.DexArchiveMergerException : dex를 병합 할 수 없습니다.
전체 오류는 다음과 같습니다.
Executing tasks: [:app:assembleDebug]
AGPBI: {"kind":"warning","text":"The `android.dexOptions.incremental` property is deprecated and it has no effect on the build process.","sources":[{},{}]}
Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead.
:app:buildInfoDebugLoader
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:checkDebugManifest UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:prepareLintJar UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:createDebugCompatibleScreenManifests UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:splitsDiscoveryTaskDebug UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources
:app:javaPreCompileDebug UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:mergeDebugShaders UP-TO-DATE
:app:compileDebugShaders UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:packageInstantRunResourcesDebug UP-TO-DATE
:app:checkManifestChangesDebug
:app:extractTryWithResourcesSupportJarDebug UP-TO-DATE
:app:transformClassesWithStackFramesFixerForDebug UP-TO-DATE
:app:transformClassesWithDesugarForDebug UP-TO-DATE
:app:transformClassesWithExtractJarsForDebug UP-TO-DATE
:app:transformClassesWithInstantRunVerifierForDebug UP-TO-DATE
:app:transformClassesWithDependencyCheckerForDebug UP-TO-DATE
:app:compileDebugNdk NO-SOURCE
:app:mergeDebugJniLibFolders UP-TO-DATE
:app:transformNativeLibsWithMergeJniLibsForDebug UP-TO-DATE
:app:processDebugJavaRes NO-SOURCE
:app:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
:app:transformNativeLibsAndResourcesWithJavaResourcesVerifierForDebug UP-TO-DATE
:app:transformClassesWithInstantRunForDebug UP-TO-DATE
:app:transformClassesEnhancedWithInstantReloadDexForDebug UP-TO-DATE
:app:incrementalDebugTasks UP-TO-DATE
:app:preColdswapDebug
:app:fastDeployDebugExtractor UP-TO-DATE
:app:generateDebugInstantRunAppInfo UP-TO-DATE
:app:transformClassesWithInstantRunSlicerForDebug UP-TO-DATE
:app:transformClassesWithDexBuilderForDebug UP-TO-DATE
:app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
:app:buildInfoGeneratorDebug
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 2s
39 actionable tasks: 5 executed, 34 up-to-date
build.gradle
앱 모듈을 통해 Multidex 활성화
multiDexEnabled true
아래와 같음-
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.xx.xxx"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true //Add this
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
그런 다음 아래 단계를 따르십시오.
- 로부터
Build
메뉴 ->를 눌러Clean Project
버튼을 누릅니다. - 작업이 완료되면 메뉴 에서
Rebuild Project
버튼을Build
누릅니다. - 메뉴에서
File -> Invalidate cashes / Restart
compile
되어 지금은 사용되지 는 사용하는 것이 좋습니다 그래서 implementation
나api
I am using Android Studio 3.0 and was facing the same problem. I add this to my gradle:
multiDexEnabled true
And it worked!
Example
android {
compileSdkVersion 27
buildToolsVersion '27.0.1'
defaultConfig {
applicationId "com.xx.xxx"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true //Add this
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
반응형
'code' 카테고리의 다른 글
Bash : 날짜 반복 (0) | 2020.11.26 |
---|---|
onAttach ()가 Fragment에서 호출되지 않았습니다. (0) | 2020.11.26 |
투명한 단일 픽셀 이미지의 최소 파일 크기 (0) | 2020.11.26 |
angularjs에서 선택 상자의 기본값을 어떻게 설정합니까? (0) | 2020.11.26 |
프로세스가 도커 컨테이너 내에서 실행 중인지 확인하는 방법 (0) | 2020.11.26 |