Unity3D how to enable --stacktrace

2020-07-25 01:12发布

问题:

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!

回答1:

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



回答2:

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
    


标签: unity3d