Error:Execution failed for task ':app:transformClassesWithDexForDebug'.

1. The error message is as follows:

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.dex.DexException: Multiple dex files define Lcom/alibaba/fastjson/JSONStreamAware;

Write picture description here

Today, after migrating the project from Windows to Mac, compiling and running, Android Studio reported the error shown above. So began to search for query solutions. Because there are many reasons for the error transformClassesWithDexForDebug, the problems encountered by everyone on the Internet are all the same, and the solutions are different. After trying several solutions provided on the Internet, to no avail. So, thinking about it, starting from the error log, and reading the error message carefully, I found the breakthrough point:

com.android.dex.DexException: Multiple dex files define Lcom/alibaba/fastjson/JSONStreamAware;

So, check the content related to fastjson in the project. Guessing the jar package conflicts, fastjson is quoted in both places. Sure enough, it was found that not only fastjson was referenced in build.gradle, but also a fastjson jar package existed in libs under app, and the two versions were inconsistent. So after deleting the fastjson jar package in libs, recompiling and running, the problem is solved perfectly~

2. The error message is as follows:

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.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat
$AccessibilityServiceInfoVersionImpl;

Write picture description here

After migrating the project from eclipse to Android Studio today, compiling and running, Android Studio reported the error shown above. So began to search for query solutions. Because there are many reasons for the error transformClassesWithDexForDebug, the problems encountered by everyone on the Internet are all the same, and the solutions are different. So, thinking about it, starting from the error log, and reading the error message carefully, I found the breakthrough point:

com.android.dex.DexException: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat
$AccessibilityServiceInfoVersionImpl;

Therefore, based on previous experience, to check the contents of the project related to the v4 package. Guessing the jar package conflicts, the v4 package is imported in both places. Sure enough, it was found that not only the v4 package was referenced in build.gradle, but also there was a v4 package in the libs under the app, and the two versions were inconsistent. So after deleting the v4 package in libs, recompiling and running, the problem is solved perfectly~

Different error logs have the same error cause. Learn from the lessons and be more careful and considerate when importing and transplanting projects in the future.

Guess you like

Origin blog.csdn.net/CHITTY1993/article/details/53712971