org.gradle.api.tasks.TaskExecutionException:任务':app:transformClassesWithDexForDebug'的执行失败

新手上路,请多包涵

由于 65K 我的项目中的错误,我需要它迁移到 Android Studio 。在跑步的时候

./gradlew assembleDebug

我收到错误消息:

 Execution failed for task ':app:transformClassesWithDexForDebug'.
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 '/opt/jdk/jdk1.8.0_45/bin/java'' finished with non-zero exit value 1

我知道这是在将 Eclipse 项目迁移到 Android Studio 时都会遇到的非常常见的错误。

我努力了:

任务“:app:transformClassesWithDexForDebug”执行失败 - Gradle 依赖项?

为 Android 实现 Google 登录时任务“:app:transformClassesWithDexForDebug”执行失败

Android Studio TransformException:错误:任务’:app:transformClassesWithDexForDebug’的执行失败

错误:任务“:app:transformClassesWithDexForDebug”执行失败

com.android.build.transform.api.TransformException

https://github.com/journeyapps/zxing-android-embedded/issues/110

我尝试了所有解决方案,我尝试在我的项目中一个一个地添加 .jar 文件,我只使用了那些在我的项目中使用的谷歌服务包,我什至添加了 multidex jar.But 没有什么能帮助我

我的 Build.gradle 文件:

 apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.petzview.android"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    lintOptions {
        abortOnError false
        checkReleaseBuilds false
    }

    dexOptions {
        incremental = true;
        maxProcessCount 4
        javaMaxHeapSize "4g"
        dexInProcess = false
        preDexLibraries = false
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.google.android.gms:play-services-ads:9.0.0'
    compile 'com.google.android.gms:play-services-plus:9.0.0'
    compile 'com.google.android.gms:play-services-gcm:9.0.0'
    compile project(':AVIOCtrlDefine')
    compile project(':Facebook')
    compile project(':SlidingMenu-master')
    compile 'com.android.support:multidex:1.0.1'
}
android.packagingOptions {
    exclude 'the META-INF / DEPENDENCIES'
    exclude 'META-INF/DEPENDENCIES.txt'
    exclude 'the META-INF / LICENSE'
    exclude 'the META-INF / LICENSE.txt'
    exclude 'the META-INF / license.txt'
    exclude 'the META-INF / NOTICE'
    exclude 'the META-INF / the NOTICE.txt '
    exclude ' the META-INF / NOTICE.txt '
    exclude ' the META-INF / ASL2.0 '
    exclude ' the META-INF / Services / javax.annotation.processing.Processor '
}
apply plugin: 'com.google.gms.google-services'

我的主要毕业文件:

 buildscript {
    repositories {
        jcenter()
    }
    dependencies {
       classpath 'com.android.tools.build:gradle:2.1.0'
       classpath 'com.google.gms:google-services:3.0.0'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

我的 libs 文件夹的屏幕截图:

我的应用程序.java:

 public class MyApplication extends MultiDexApplication {
    private Object mTempObject = null;

    private boolean flagHomeFragmentFirstCreate = true;

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

我的清单类包含 MyApplication:

  <application
        android:name=".MyApplication"
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:largeHeap="true"
        android:theme="@style/AppTheme">

运行后

./gradlew assembleDebug –stacktrace

错误日志

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformClassesWithDexForDebug'.
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)
         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.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:51)
at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:28)
at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:43)
at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:170)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
at org.gradle.launcher.Main.doAction(Main.java:33)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:30)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
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
 '/opt/jdk/jdk1.8.0_45/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)
         ... 60 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
 '/opt/jdk/jdk1.8.0_45/bin/java'' finished with non-zero exit value 1
at com.android.build.gradle.internal.transforms.DexTransform.transform(DexTransform.java:421)
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)
         ... 69 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
 '/opt/jdk/jdk1.8.0_45/bin/java'' finished with non-zero exit value 1
at com.android.builder.core.AndroidBuilder.dexOutOfProcess(AndroidBuilder.java:1553)
at com.android.builder.core.AndroidBuilder.runDexer(AndroidBuilder.java:1495)
at com.android.builder.core.AndroidBuilder.convertByteCode(AndroidBuilder.java:1482)
 at com.android.build.gradle.internal.transforms.DexTransform.transform(DexTransform.java:251)
         ... 72 more Caused by: java.util.concurrent.ExecutionException:
com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException: Process 'command
 '/opt/jdk/jdk1.8.0_45/bin/java'' finished with non-zero exit value 1
at com.android.builder.core.AndroidBuilder.dexOutOfProcess(AndroidBuilder.java:1549)
        ... 75 more Caused by: com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException: Process 'command
 '/opt/jdk/jdk1.8.0_45/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$3.call(AndroidBuilder.java:1538)
at com.android.builder.core.AndroidBuilder$3.call(AndroidBuilder.java:1531)
Caused by: org.gradle.process.internal.ExecException: Process 'command
 '/opt/jdk/jdk1.8.0_45/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

在设备上运行应用程序时出错:

错误:处理“java/awt/font/NumericShaper.class”时出现问题:错误:不建议或错误地使用核心类(java.* 或 javax.*) 错误:未构建核心库时。错误:这通常是由于在使用 IDE(例如 Error:Eclipse)时无意中包含了核心库文件错误:在应用程序的项目中。如果你确定你不是故意定义一个 Error:core 类,那么这是对 Error:going 的最可能的解释。错误:但是,您实际上可能正在尝试在核心错误:命名空间中定义一个类,您可能已经获取了它的来源,例如,错误:来自非 Android 虚拟机项目。这将最错误:肯定行不通。至少,它会危害您的应用程序与平台未来版本的兼容性。错误:它的合法性也经常受到质疑。错误:如果您真的打算构建一个核心库——这只是错误:适合作为创建完整虚拟机的一部分错误:分发,而不是编译应用程序——然后使用错误:“–core-library “ 选项来抑制此错误消息。错误:如果您继续使用“–core-library”,但实际上是错误:构建应用程序,那么请预先警告您的应用程序错误:在某些时候仍然无法构建或运行。请做好错误:为愤怒的客户做好准备,例如,一旦他们升级他们的操作错误:系统,您的错误:应用程序就会停止运行。你会为这个问题负责。错误:如果您合法地使用了恰好位于 Error:core 包中的某些代码,那么您拥有的最简单安全的替代方法是 Error:repackage 该代码。也就是说,将有问题的类移动到错误:您自己的包命名空间中。这意味着它们永远不会出现错误:与核心系统类冲突。 JarJar 是一个可以帮助 Error:you 的工具。如果你发现你无法做到这一点,那么错误:这表明你所走的道路最终会错误:导致痛苦、苦难、悲伤和悲叹。错误:1个错误;中止错误:任务“:app:transformClassesWithDexForDebug”执行失败。

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’/usr/lib/jvm/java-8-oracle/bin/java”以非零退出值1完成信息:BUILD FAILED

我哪里错了?

原文由 AndroidLearner 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 1.4k
1 个回答

检查 build.gradle (模块:Android)为我解决了问题。

将其修改为可用版本。

 android {
    buildToolsVersion '23.0.1'
}

原文由 Beatrice Lin 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
logo
Stack Overflow 翻译
子站问答
访问
宣传栏