문제는 debug
모드로 변경하면 앱을 실행할 수 있지만 release
모드로 전환하면 실패한다는 것 입니다.
예외:
**FAILURE: Build failed with an exception.**
> Execution failed for task ':app:transformClassesWithDexForRelease'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
stacktrace로 gradle build 명령을 실행하면 이것이 내가 얻는 것입니다.
./gradlew app:transformClassesWithDexForRelease --stacktrace
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
*Exception is:*
>org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformClassesWithDexForRelease'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:25)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:110)
at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23)
at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43)
at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)
at org.gradle.initialization.DefaultGradleLauncher$4.run(DefaultGradleLauncher.java:154)
at org.gradle.internal.Factories$1.create(Factories.java:22)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:52)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:151)
at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32)
at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:99)
at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:93)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:62)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:93)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:82)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:94)
at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:43)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:78)
at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:48)
at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:52)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
at org.gradle.util.Swapper.swap(Swapper.java:38)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.health.DaemonHealthTracker.execute(DaemonHealthTracker.java:47)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:66)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:72)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.health.HintGCAfterBuild.execute(HintGCAfterBuild.java:41)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:246)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
Caused by: java.lang.RuntimeException: com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
at com.android.builder.profile.Recorder$Block.handleException(Recorder.java:54)
at com.android.builder.profile.ThreadRecorder$1.record(ThreadRecorder.java:57)
at com.android.builder.profile.ThreadRecorder$1.record(ThreadRecorder.java:47)
at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:173)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:244)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:220)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.execute(AnnotationProcessingTaskFactory.java:231)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:209)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
... 68 more
Caused by: com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
at com.android.build.gradle.internal.transforms.DexTransform.transform(DexTransform.java:422)
at com.android.build.gradle.internal.pipeline.TransformTask$3.call(TransformTask.java:178)
at com.android.build.gradle.internal.pipeline.TransformTask$3.call(TransformTask.java:174)
at com.android.builder.profile.ThreadRecorder$1.record(ThreadRecorder.java:55)
... 77 more
Caused by: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
at com.android.builder.core.AndroidBuilder.runDexer(AndroidBuilder.java:1472)
at com.android.builder.core.AndroidBuilder.convertByteCode(AndroidBuilder.java:1389)
at com.android.build.gradle.internal.transforms.DexTransform.transform(DexTransform.java:250)
... 80 more
Caused by: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
at com.android.builder.core.AndroidBuilder.runDexer(AndroidBuilder.java:1456)
... 82 more
Caused by: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
at com.android.build.gradle.internal.process.GradleProcessResult.assertNormalExitValue(GradleProcessResult.java:43)
at com.android.builder.core.AndroidBuilder$2.call(AndroidBuilder.java:1464)
at com.android.builder.core.AndroidBuilder$2.call(AndroidBuilder.java:1456)
Caused by: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:367)
at com.android.build.gradle.internal.process.GradleProcessResult.assertNormalExitValue(GradleProcessResult.java:41)
... 2 more
나는 사용하고있다
- 안드로이드 스튜디오 2.0 베타 6
- Java 버전 : Java (TM) SE 런타임 환경 (빌드 1.8.0_73-b02)
- Gradle 버전 : com.android.tools.build:gradle:2.0.0-beta6
- 그리고 멀티 덱스를 활성화했습니다
내 build.gradle 파일
apply plugin: 'com.android.application'
apply plugin: 'com.getkeepsafe.dexcount'
android {
def VERSION_CODE = 52
def VERSION_NAME = "1.0"
compileSdkVersion 23
buildToolsVersion '23.0.2'
defaultConfig {
applicationId "com.example.app"
manifestPlaceholders = [appName: "Personal App"]
minSdkVersion 14
targetSdkVersion 23
renderscriptTargetApi 19
renderscriptSupportModeEnabled true
versionCode VERSION_CODE
versionName VERSION_NAME
// Enabling multidex support.
multiDexEnabled true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
encoding = 'UTF-8'
}
signingConfigs {
livekeystore {
storeFile file('../key.jks')
keyAlias 'livekeystore'
keyPassword '123asd'
storePassword '123asd'
}
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
zipAlignEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
signingConfig signingConfigs.burgerking
manifestPlaceholders = [googleMapsKey: "@string/release_google_map_key", appNameSuffix: ""]
}
debug {
applicationIdSuffix '.dev'
debuggable true
minifyEnabled false
shrinkResources false
zipAlignEnabled false
manifestPlaceholders = [googleMapsKey: "@string/debug_google_map_key", appNameSuffix: ' (Dev-' + VERSION_CODE + ')']
}
}
dexOptions {
incremental true
javaMaxHeapSize "4g" // 2g should be also OK
}
useLibrary 'org.apache.http.legacy'
}
repositories {
maven { url 'https://mint.splunk.com/gradle/' }
maven { url "http://dl.bintray.com/populov/maven" }
mavenCentral()
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.4.2'
classpath 'com.newrelic.agent.android:agent-gradle-plugin:4.244.0'
}
}
dependencies {
compile 'com.google.code.gson:gson:2.4'
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:recyclerview-v7:23.2.0'
compile 'com.android.support:cardview-v7:23.2.0'
compile 'com.android.support:design:23.2.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.android.gms:play-services-base:8.4.0'
compile 'com.google.android.gms:play-services-location:8.4.0'
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.google.android.gms:play-services-maps:8.4.0'
compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'com.googlecode.libphonenumber:libphonenumber:7.0.5'
compile 'com.facebook.android:facebook-android-sdk:4.1.1'
compile 'de.greenrobot:eventbus:2.4.0'
compile 'com.viewpagerindicator:library:2.4.1@aar'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.squareup:pollexor:2.0.2'
compile 'com.makeramen:roundedimageview:2.1.0'
compile 'com.mcxiaoke.volley:library:1.0.16@aar'
compile files('libs/now-auth-api.jar')
compile 'com.jakewharton:butterknife:5.1.2'
compile 'com.github.ksoichiro:android-observablescrollview:1.2.0'
compile 'io.card:android-sdk:5.3.0'
compile 'com.appboy:android-sdk-ui:1.10.3'
testCompile 'junit:junit:4.11'
testCompile('org.mockito:mockito-core:1.9.5') {
exclude group: 'org.hamcrest'
}
testCompile('org.powermock:powermock-module-junit4:1.5') {
exclude group: 'org.hamcrest'
}
testCompile('org.powermock:powermock-api-mockito:1.6.2') {
exclude group: 'org.hamcrest'
}
compile 'me.grantland:autofittextview:0.2.1'
}
릴리스 릴리스를 제거하면 작동시킬 수 minifyEnabled true
있습니다. 그 이유는 무엇입니까, 다른 해결 방법이 있습니까?
답변
나는이 코드를 고쳤다.
local.properties
org.gradle.jvmargs=-XX\:MaxHeapSize\=512m -Xmx512m
그리고 gradle 에서이 작업을 수행해야합니다
defaultConfig {
applicationId "yourProjectPackage"
minSdkVersion 15
versionCode 1
versionName "1.0"
targetSdkVersion 23
multiDexEnabled true //important
}
답변
당신이 만드는 경우 multiDexEnabled = true
응용 프로그램의 defaultConfig, 당신은 원하는 결과를 얻을 것이다.
defaultConfig {
minSdkVersion 14
targetSdkVersion 22
multiDexEnabled = true
}
답변
나를 위해 프로젝트에서 파일을 제거한 후 문제가 해결 되었습니다 jar
. jar
내 프로젝트 의 파일 중 하나가 이전 버전의을 사용하고있는 것 같습니다 google play services
.
답변
나는 또한 같은 오류를 받았다 :
오류 : ‘: app : transformClassesWithDexForDebug’작업에 대한 실행이 실패했습니다. com.android.build.api.transform.TransformException : java.lang.RuntimeException : com.android.ide.common.process.ProcessException : java.util.concurrent.ExecutionException : com.android.ide.common.process.ProcessException : org.gradle.process.internal.ExecException : 프로세스 ‘command’C : \ Program Files \ Java \ jdk1.8.0_60 \ bin \ java.exe ‘가 0이 아닌 종료 값 1로 완료되었습니다.
잘 나는 다음 단계의 도움으로 이것을 고쳤다.
-
앱의 build.gradle (프로젝트 루트가 아닌)을 열고 다음을 추가하십시오.
android { //snippet //add this into your existing 'android' block dexOptions { javaMaxHeapSize "4g" } //snip }
-
빌드를 다시 시도하십시오.
참고 : 4g는 4 기가 바이트이며 이는 dex 작업의 최대 힙 크기입니다.
답변
MULTIDEX 불필요, 반복, MULTIDEX 불필요
자세히 설명하자면 : Multidex는 기본적으로 Android와 함께 제공되는 도구이며이를 true로 설정하면 64,000 개가 넘는 메서드가있는 앱은 약간 변경된 빌드 프로세스를 사용하여 컴파일 할 수 있습니다. 그러나 오류가 다음과 같은 경우에만 멀티 덱스를 사용해야합니다.
출력 쓰기 문제 : 너무 많은 필드 참조 : 131000; max는 65536입니다. –multi-dex 옵션을 사용해보십시오.
또는 이런
Dalvik 형식으로 변환하지 못했습니다 : dex를 실행할 수 없습니다 : [0, 0xffff]에없는 메소드 ID : 65536
그러나 그것은 아니다 여기서는 ! here (나를 위해) 문제는 build.gradle 파일의 종속성으로 인해 발생합니다.
해결책:
특정 종속성을 활용하십시오. 종속성의 전체 섹션을 가져 오지 마십시오!
예를 들어 위치에 대한 Play 서비스 종속성이 필요한 경우 가져 오기만 .
하다:
compile 'com.google.android.gms:play-services-location:11.0.4'
하지 말 것 :
compile 'com.google.android.gms:play-services'
이 문제를 일으킬 수있는 또 다른 문제는 사용중인 외부 라이브러리의 일종 일 수 있으며, 이는 이전 버전의 종속성을 참조합니다. 이 경우 다음 단계를 수행하십시오.
- SDK 관리자로 이동하여 종속성 업데이트를 설치하십시오.
- build.gradle 파일이 최신 버전을 표시하는지 확인하십시오. 최신 버전을 얻으려면 다음 링크를 사용하십시오.
https://developers.google.com/android/guides/setup - 최신 버전을 참조하도록 라이브러리를 편집하거나 업데이트 된 버전이있는 경우 설치하십시오.
이 질문이 오래되었다는 것을 알고 있습니다. 앱의 수 잠재적으로 ANR의 원인이 아무 이유없이 multidex를 사용하기 때문에, 거기이 답변을 받으실 수 있습니다! 멀티 덱스가 필요한 경우에만 사용하고 그것이 무엇인지 이해 한 경우에만 사용하십시오.
나 자신도 멀티 덱스없이이 문제를 해결하기 위해 몇 시간을 보냈으며, 발견 한 내용을 공유하고 싶었습니다.
답변
앱 수준의 defaultConfig에 multiDexEnabled
true 를 추가하십시오 gradle
.
defaultConfig {
applicationId "your application id"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner"android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
답변
내 앱에서 비슷한 문제가 발생했습니다. 여기 내가 한 일이 있습니다.
1. 모듈의 build.gradle에 이것을 추가하십시오 : app
multiDexEnabled = true
따라서 코드는 다음과 같습니다.
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example..."
minSdkVersion 17
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled = true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
이것은 나를 위해 일했습니다. 희망이 당신에게도 도움이되기를 바랍니다 🙂
같은 프로젝트에서 Firebase 도 사용하고있었습니다 . 따라서 multiDexEnabled를 사용하면 Firebase for Lollipop 기기의 다른 문제가 발생할 수 있습니다 . 일부 FireBase 클래스가 식별되지 않았습니다. ( com.google.firebase.provider 공급자를 얻을 수 없음 ).
이를 해결하는 방법이 여기 에 설명되어 있습니다.