Unity3D how to enable --stacktrace

2020-07-25 01:33发布

I'm getting this error when building gradle.

  • What went wrong: Execution failed for task ':transformClassesWithJarMergingForRelease'.

    com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/common/util/VisibleForTesting.class

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

I will solve this problem if I can see which modules are conflicting. Any help appreciated!

标签: unity3d
2条回答
在下西门庆
2楼-- · 2020-07-25 01:50

Because this happened to me and I was stuck trying to figure this one out myself. You can copy the gradle command from the error message in Unity and execute gradle yourself.

  1. Run Gradle in Unity and wait for the error.
  2. Copy the command from the "CommandInvokationFailure: Gradle build failed." error message in the Unity console, in my case:

    java.exe -classpath "C:\Program Files\Unity\Hub\Editor\2017.4.24f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-4.6.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"
    
  3. Open a terminal and navigate to \Temp\gradleOut\

  4. Add --stacktrace on the command above:

    java.exe -classpath "C:\Program Files\Unity\Hub\Editor\2017.4.24f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-4.6.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease" --stacktrace
    
查看更多
在下西门庆
3楼-- · 2020-07-25 02:06

If you open up the Player Settings you'll find logging options (on the bottom). The logging options apply to all build targets, they are influencing the stacktrace.

The default setting is Script Only which only outputs the managed stacktrace. If you set it to "full" you'll also get the native stacktrace, which might help in your case.

https://docs.unity3d.com/ScriptReference/StackTraceLogType.html

查看更多
登录 后发表回答