android 新楓之谷因不明錯誤任務執行失敗 - Android-錯誤:任務執行失敗':app:transformClassesWithDexForRelease'




13 Answers

我修正它只是這個代碼。

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
}

問題是,當我切換到debug模式時,我能夠運行我的應用程序,但是當我切換到release模式時它失敗。

例外:

失敗:生成失敗,出現異常。

任務':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:處理'command'/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/bin/java''以非零退出值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:處理'命令'/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/bin/java''以非零退出值1結束

例外是:

org.gradle.api.tasks.TaskExecutionException:任務':app:transformClassesWithDexForRelease'的執行失敗。 在org.gradle上的org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)處的org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69) .org.gradle.api.internal上的org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)中的.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35) .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.ExecuteAtMostOnceTaskExecu 在org.gradle.execution.taskgraph.DefaultTaskGraphExeterter $ EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:$)上的org.gradle.execution.taskgraph.DefaultTaskGraphExeterter $ EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)上的ter.execute(ExecuteAtMostOnceTaskExecuter.java:43) 185)org.gradle.execution.taskgraph.Abs​​tractTaskPlanExecutor $ TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66)at org.gradle.execution.taskgraph.Abs​​tractTaskPlanExecutor $ 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.access $ org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)(DefaultBuildExecuter.jav a: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)在org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)在org.gradle.initialization.DefaultGradleLauncher $ 4.run(DefaultGradleLauncher.java:154)在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。 org.gradle.initialization.DefaultGradleLauncher.access中的gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:151)$ org.gradle.initialization.DefaultGradleLauncher $ 200(DefaultGradleLauncher.java:32)$ 1.create(DefaultGradleLauncher.java:99)在org。 在org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java)上的org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)上的gradle.initialization.DefaultGradleLauncher $ 1.create(DefaultGradleLauncher.java:93) :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。在org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)處運行(InProcessBuildActionExecuter.java:94)org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28) .org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:43)at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)at org .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 ),位於org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)處的org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)。 gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSi (org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)at org.gradle.launcher.daemon.server.exec.ForwardClientInput $ 2.call(ForwardClientInput.java)(ngleUsedDaemon.java:34) :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.Daemo 在org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute處的org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:72)處的nCommandExecution.proceed(DaemonCommandExecution.java:120) BuildCommandOnly.java:36)在org.gradle.launcher.daemon.server.health.HintGCAfterBuild.execute(HintGCAfterBuild.java:org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120) 41)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)引起: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:進程'command'/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/bin/java''在com.android.builder.profile處以非零的退出值1結束。 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:在org.gradle.api的org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)上的com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:173) .internal.project.taskfactory.AnnotationProcessingTaskFactory $ IncrementalTask​​Action.doExecute(AnnotationProcessingTaskFactory.java:244)at org.gradle.api.internal.project.taskfactory.AnnotationProcessi ngTaskFactory $ StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:220)位於org.gradle.api.internal.project.taskfactory的org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory $ IncrementalTask​​Action.execute(AnnotationProcessingTaskFactory.java:231)。 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更多信息: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:進程'命令'/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/bin/java''以非結束 - 零出口 值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引起: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''在com.android.builder.core.AndroidBuilder.runDexer(AndroidBuilder.java:1472)com上以非零退出值1結束。 android.builder.core.AndroidBuilder.convertByteCode(AndroidBuilder.java:1389)at com.android.build.gradle.internal.transforms.DexTransform.transform(DexTransform.java:250)... 80更多引起:java.util .concurrent.E xecutionException: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' '在com.android.builder.core.AndroidBuilder.runDexer(AndroidBuilder.java:1456)中完成了非零的退出值1 ... 82更多引起來自:com.android.ide.common.process.ProcessException:org。 gradle.process.internal.ExecException:進程'命令'/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/bin/java''在com.android.build處以非零退出值1結束。 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)引起:org.gradle.process.internal.ExecException:進程'命令'/Library/Java/JavaVirtualMachines/jdk1.8.0_73.jdk/Contents/Home/bin/java''零 在com.android.build.gradle.internal.process.GradleProcessResult.assertNormalExitValue(GradleProcessResult.java:41)... org.gradle.process.internal.DefaultExecHandle處退出值1 ... $ ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:367)...另外2個

我在用

  • Android Studio 2.0 Beta 6
  • Java版本:Java(TM)SE運行時環境(build 1.8.0_73-b02)
  • Gradle版本:com.android.tools.build:gradle:2.0.0-beta6
  • 我啟用了Multidex

我的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:[email protected]'
    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:[email protected]'
    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 。 那麼為什麼還有另一種解決方法




對我來說,我從我的項目中刪除jar文件後,問題就解決了 。 似乎我的項目中的一個jar文件使用的是舊版本的google play services




我的應用程序中有類似的問題。 這是我做的。

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 Pre棒棒堂設備發生另一個問題。 一些FireBase類沒有被識別。 ( 無法獲取提供商com.google.firebase.provider )。
解決這個問題的方法在here.解釋here.




當將Google Play服務從7.5升級到9.0時,出現此錯誤

出現以下錯誤:

compile 'com.google.android.gms:play-services:9.0.0'

當我改變

compile 'com.google.android.gms:play-services:7.5.0'

沒有錯誤。 嘗試這個




那麼,我相信這個問題得到了回答並被接受。 但我要寫下我面臨的問題以及我如何解決問題。

我也收到了同樣的錯誤:

錯誤:任務':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:進程'命令'C:\ Program Files \ Java \ jdk1.8.0_60 \ bin \ java.exe''以非零退出值1結束

我沒有幸運地應用所有設置並獲得成功。 但是當我試圖再次調試該項目。 這次我得到了三個錯誤(包括上面):

錯誤:Java HotSpot(TM)64位服務器VM警告:CodeCache已滿。 編譯器已被禁用。

錯誤:Java HotSpot(TM)64位服務器VM警告:嘗試使用-XX增加代碼緩存大小:ReservedCodeCacheSize =

那麼我做了什麼? 我只是去Android Studio:

文件>使緩存失效/重新啟動..>無效並重新啟動

快速解決!

額外注意:

我在Gradle Console中找到的:

:app:incrementalDebugTasks:app:prePackageMarkerForDebug:app:fastDeployDebugExtractor:app:generateDebugInstantRunAppInfo:app:transformClassesWithDexForDebug為了在進程中運行dex,Gradle守護進程需要一個更大的堆。 它目前大約有910 MB。 要獲得更快的構建,請將Gradle守護程序的最大堆大小增加到2048 MB以上。 要執行此操作,請在項目gradle.properties中設置org.gradle.jvmargs = -Xmx2048M。 有關更多信息,請參閱https://docs.gradle.org/current/userguide/build_environment.html FAILED

在Oracle博客上閱讀更多內容




我剛剛寫了這個代碼到gradle.properties中,現在沒問題

org.gradle.jvmargs=-XX:MaxHeapSize\=2048m -Xmx2048m



我知道這是一個老問題,但仍然存在。 每當這發生在我身上時,這是因為我已經包含了所有的播放服務庫。 只需在build.gradle(模塊)文件中將play-services:xxx更改為play-service-:xxx即可




我更新jdk到1.8.0_74,Adnroid-studio到2.1預覽版1並添加到應用程序文件

@Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(base);
    MultiDex.install(this);
}



build.gradle添加這一行

 defaultConfig {
    ............
    aaptOptions.cruncherEnabled = false
    aaptOptions.useNewCruncher = false
    compileOptions.encoding = 'ISO-8859-1'
    multiDexEnabled true
}



Sol 1:build.gradle

defaultConfig {
    multiDexEnabled true
}

清理你的項目並重建。

溶膠2:local.properties添加,

org.gradle.jvmargs=-XX\:MaxHeapSize\=512m -Xmx512m

溶膠3

compile 'com.android.support:multidex:1.0.1'

否則在您的應用程序中添加全部3個。




我修復了我添加到我的項目 > app > libs android volley.jar並解決了我的問題




Solved the same problem by just adding a line to buid.gradle(app level) add this line to defaultConfig

multiDexEnabled = true



This happened to me even on debug builds and just cleared all the module level and project level build folders and it worked, yeah just like that.




Related