Org.gradle.api.tasks.TaskExecutionException: execution failed for task ': app: transformClassesWithDexForDebug'

Due to a 65K error in my project, I need to port it to Android Studio. While running

./gradlew assemblyDebug

I get an error:

 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 

I know this is a very common error that occurs when porting an Eclipse project to Android Studio.

I have tried:

Could not complete task ': app: transformClassesWithDexForDebug' - Gradle Dependencies?

Could not complete task ': app: transformClassesWithDexForDebug' while implementing Google login for Android

Android Studio TransformException: Error: Could not complete task ': app: transformClassesWithDexForDebug'

Error: Could not complete task ': app: transformClassesWithDexForDebug'

com.android.build.transform.api.TransformException

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

I tried every solution, I tried to add .jar files one by one to my project, I used only those Google service packages that are used in my project, I even added multidex jar. multidex nothing helps me

My Build.gradle file:

 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' 

My main Gradle file:

 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() } } 

Screenshot of my libs folder:

MyApplication.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()); } 

My manifest class containing 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"> 

After launch

./gradlew assemblyDebug --stacktrace

Error log

 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 

Error starting application on device:

Error: problem processing "java / awt / font / NumericShaper.class": Error: incorrect or erroneous use of the main class (java. * Or javax. *). Error: when the main library is not created. Error: This often happens due to the inadvertent inclusion of a base library file. Error: in the application project when using the IDE (for example, Error: Eclipse). If you are sure that you are not intentionally defining the Error: core class, then this is the most likely explanation for what happens in Error :. Error: However, you may be trying to define a class in the kernel “Error: namespace”, the source of which you could use, for example, “Error: from a virtual machine project other than Android”. That will be most of the mistakes: of course, it does not work. At a minimum, this jeopardizes Error: your application is compatible with future versions of the platform. Mistake: this is also often of dubious legality. Error: If you really intend to create a base library - that is the only mistake: it fits as part of creating a full-fledged virtual machine Error: distribution, not compilation of the application - then use the Error: "--core-library" option to suppress this error message. Error: If you continue to use "--core-library", but in fact it is Error: creating an application, then warn that Application Error: at some point, it will fail to build or run. Please be a mistake: prepare for dissatisfied clients who, for example, find that your error: the application stops functioning after updating the operating system Error: system. You will be to blame for this problem. Error: If you are legally using some kind of code that is in the main Error: core package, then the simplest and safest alternative is “Error: repackage this code”. That is, move the classes in question to Error: your own package namespace. This means that they will never be wrong: they conflict with the main classes of the system. JarJar is a tool that can help. Error: You are in this endeavor. If you find that you cannot do this, then Error: this is a sign that the path you are following will ultimately be Error: lead to pain, suffering, sadness and sorrow. Error: 1 error; Reset Error: Failed while executing 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' / usr / lib / jvm / java-8-oracle / bin / java '' terminated with non-zero output value 1 Information: BUILD FAILED

Where am I going wrong?

+53
source share
21 answers

Check the fixed build.gradle problem (Module: Android).

Change it to a working version.

 android { buildToolsVersion '23.0.1' } 
+20
source

A simple solution here ... it worked for me:

  1. Clean project
  2. Project reconstruction
  3. Sync project with gradation file
+12
source

I had the same problem and I could solve it like this:

1) If your minSdkVersion set to 21 or higher , the only thing you need to do is set multiDexEnabled in your build.gradle file at the module level, as shown below:

 android { defaultConfig { ... minSdkVersion 21 targetSdkVersion 28 multiDexEnabled true } ... } 

2) However, if your minSdkVersion is set to 20 or less , you should use the MultiDex compatibility library as follows:

2.1) Modify the build.gradle file of the build.gradle level to enable MultiDex and add the MultiDex library as a dependency, as shown below

 android { defaultConfig { ... minSdkVersion 15 targetSdkVersion 28 multiDexEnabled true } ... } dependencies { implementation 'com.android.support:multidex:1.0.3' } 

2.2) In the Application class or not, do one of the following:

2.2.1) If you do not cancel the Application class, change your manifest file, android: name to <application> as shown below:

 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.myapp"> <application android:name="android.support.multidex.MultiDexApplication" > ... </application> </manifest> 

2.2.2) If you override the Application class, you must modify it to extend MultiDexApplication (if possible), as shown below:

 public class MyApplication extends MultiDexApplication { ... } 

2.2.3) In addition, if you override the Application class and cannot change the base class, you can also override the attachBaseContext() method and call MultiDex.install(this) to enable MultiDex:

 public class MyApplication extends SomeOtherApplication { @Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(this); } } 

Please use this link, it was really useful for me!

+10
source

next steps:

  1. close Android Studio (or IntelliJ IDEA )
  2. delete the .idea directory
  3. delete the .gradle directory
  4. delete all .iml files
    • find . | grep -e .iml$ | xargs rm
  5. use Android Studio to re-open the directory as a project

Terminal Commands:

 # close Android Studio rm -rf ./.idea rm -rf ./.gradle find . | grep -e .iml$ | xargs rm # use Android Studio to re-open the directory as a project 
+10
source

Try moving:

 apply plugin: 'com.google.gms.google-services' 

below:

 apply plugin: 'com.android.application' 

In the Gradle module file, make sure all Google services are at version 9.0.0 .

Make sure that only these build tools are used:

 classpath 'com.android.tools.build:gradle:2.1.0' 

Make sure in gradle-wrapper.properties:

 distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip 

After all of the above is true, make the menu File → Invalidate cache and restart.

+3
source

I struggled with this problem for 2 days. And I tried all the options. Finally, I noticed that after updating my Android studio, he did not show me compilation errors like @vd written above. My problem: in my build files, I used compilation (which should be replaced by an implementation or api ) and testcompile (which is also replaced by testimplementation ). Please note that I changed all the assembly files (android, app and others - in my case I also had a library of folding cells)

for example instead

 compile project(path: ':folding-cell') 

write it

 implementation project(path: ':folding-cell') 
+3
source

I disabled the instant start function from the settings, and the problem was resolved.

+2
source

your manifest application name must contain the application class name. how

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

for me it was just a small compilation error and, unfortunately, Android Studio does not show it. please do a manual search. trying to turn on offline work and clean and rebuild may help you more

+1
source

Its just, just, the compiler Didn’t accept the last changes you made, so go to the last file you made the change. It will show the error by simply changing it and recompiling.

+1
source

Apply in ProGuard Rules

 -ignorewarnings 
+1
source

My simple answer is and the only solution ...

Please check the layout files you added last, there MUST be an error in the .xml file.

We can just copy and paste the XML file from another project, but something is missing from the XML file.

An error in the .xml file will be one of the following ....

  1. Something is missing in the Drawable or String.xml or Dimen.xml folder ...

After placing all the available code in the appropriate folders, be sure to clear the project ...

+1
source

Add multiDexEnabled to Gradle (application level) as follows:

 defaultConfig { ... ... multiDexEnabled true } 
+1
source

For me, the only thing that works is to add to the repositories

 maven { url "https://maven.google.com" } 

It should look like this:

 allprojects { repositories { jcenter() maven { url "https://maven.google.com" } } 
0
source

For my case, I follow the steps from Firebase and by mistake I put it in the wrong file.

Then I returned to the project from Project on Android . Once in the Android view I inserted the file /projectname/app/YOUR-FILE-HERE and now you need to compile again.

0
source

Just delete this line from build.gradle (Project folder)

 apply plugin: 'com.google.gms.google-services' 

Now reinstall the application. works great

0
source

I had a similar problem because the Lombok plugin did not work with the new gradle. Just removed these lines:

 compileOnly 'org.projectlombok:lombok:1.18.4' annotationProcessor 'org.projectlombok:lombok:1.18.4' 

and the problem disappeared.

Perhaps you also have some kind of "problematic" plugin that does not get along with the new gradle)

0
source

you just change the import android.support.v7.app.ActionBarActivity; import android.support.v7.app.AppCompatActivity;

and extends AppCompatActivity

0
source

In my case, I accessed the static array of the class by reference to this class, but, as we know, we can directly access the static member through the class name. Therefore, when I replaced the reference to the class name, where I accessed this array. This fixed this error.

0
source

delete the folder of intermediate files from the application \ build \ intermediate files. then rebuild the project. it will work

0
source

Migrating to the androidX library

In Android Studio 3.2 and later, you can transfer an existing project to AndroidX by choosing Refactor > Migrate for AndroidX in the menu bar.

Source: https://developer.android.com/jetpack/androidx/migrate

0
source

Source: https://habr.com/ru/post/1274454/


All Articles