作者:好开心6327 | 来源:互联网 | 2023-08-23 14:25
Android开发在编译过程中经常会报类似如下的错误,突如其来经常会让我们不知所措。这时候最需要的就是静下心来,照着报错的提示排查问题。
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug77.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug80.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug81.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug82.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug79.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug74.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug73.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug76.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug75.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug78.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug17.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug26.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug25.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug12.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug8.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug21.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug4.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug5.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug27.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug .jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug22.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug14.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug30.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug31.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug13.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug18.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug9.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug28.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug10.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug15.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug1.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug2.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug19.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug6.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug23.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug11.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug16.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug29.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug3.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug24.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug7.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug20.jar, D:wsAutosizingTestappbuildintermediatestransformsdexBuilderdebug72.jar
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Program type already present: com.google.gson.FieldAttributes
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 17s
39 actionable tasks: 15 executed, 24 up-to-date
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.这句话是重点,但是说得不明不白的也不知道要怎么操作。
其实很简单,首先在Android Studio找到Terminal控制台(这个其实和CMD命令行控制台是一样的)
然后在控制台中输入如下指令,就可以重新编译debug版本,且带参数--stacktrace编译,如果编译失败会有失败的路径信息。
gradlew compileDebug --stacktrace
或者--info和--debug参数也用上会打印更多的log信息。
gradlew compileDebug --stacktrace --info --debug