Jump to content

Recommended Posts

Hola, os pongo en situación:

Soy nuevo en este mundo, hice un curso básico sobre Unity y C#, construyendo un juego de prueba para ordenador... a partir de ello he estado haciendo un juego de piedra papel tijera para ir aprendiendo. He ido poniéndole sistema de guardado, sistema de publicidad, cosillas que se me han ido ocurriendo para probar de todo (aunque la conexión con otros jugadores para poder jugar por servidor se me escapa completamente).

El problema 

es que, al construir la apk para android, no me dejaba debido a que no encontraba las herramientas de SDK. Me di cuenta de que no las tenía instaladas y lo hice con el Unity Hub. Ahora, al construir la apk, acaba saliendo un mensaje: "Build failure: 1 exception was raised by workers: See the Console for details". Y 60 errores rojos en la consola:

Spoiler

UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

FAILURE: Build failed with an exception.

* What went wrong:

Execution failed for task ':checkReleaseDuplicateClasses'.

> 1 exception was raised by workers:

 java.lang.RuntimeException: Duplicate class com.unity3d.ads.BuildConfig found in modules classes.jar (:UnityAds:) and classes.jar (:unity-ads:)

Duplicate class com.unity3d.ads.IUnityAdsListener found in modules classes.jar (:UnityAds:) and classes.jar (:unity-ads:)

  Duplicate class com.unity3d.ads.UnityAds found in modules classes.jar (:UnityAds:) and classes.jar (:unity-ads:)

 Duplicate class com.unity3d.ads.UnityAds$FinishState found in modules classes.jar (:UnityAds:) and classes.jar (:unity-ads:)

Duplicate class com.unity3d.ads.UnityAds$PlacementState found in modules classes.jar (:UnityAds:) and classes.jar (:unity-ads:)

Duplicate class com.unity3d.ads.UnityAds$UnityAdsError found in modules classes.jar (:UnityAds:) and classes.jar (:unity-ads:)

Duplicate class com.unity3d.ads.mediation.IUnityAdsExtendedListener found in modules classes.jar (:UnityAds:) and classes.jar (:unity-ads:)

 Duplicate class com.unity3d.ads.metadata.InAppPurchaseMetaData found in modules classes.jar (:UnityAds:) and classes.jar (:unity-ads:)

Duplicate class com.unity3d.ads.metadata.MediationMetaData found in modules classes.jar (:UnityAds:) and classes.jar (:unity-ads:)

 Duplicate class com.unity3d.ads.metadata.MetaData found in modules classes.jar (:UnityAds:) and classes.jar (:unity-ads:) 

Duplicate class com.unity3d.ads.metadata.PlayerMetaData found in modules classes.jar (:UnityAds:) and classes.jar (:unity-ads:)

 Go to the documentation to learn how to Fix dependency resolution errors.

* 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 45s

> Configure project :

Exception while marshalling C:\Program Files\Unity\Hub\Editor\2019.2.0b10\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\build-tools\28.0.3\package.xml. Probably the SDK is read-only

Exception while marshalling C:\Program Files\Unity\Hub\Editor\2019.2.0b10\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools\package.xml. Probably the SDK is read-only

Exception while marshalling C:\Program Files\Unity\Hub\Editor\2019.2.0b10\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-28\package.xml. Probably the SDK is read-only

Exception while marshalling C:\Program Files\Unity\Hub\Editor\2019.2.0b10\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\package.xml. Probably the SDK is read-only

> Task :preBuild UP-TO-DATE

> Task :preReleaseBuild

> Task :compileReleaseAidl NO-SOURCE

> Task :compileReleaseRenderscript NO-SOURCE

> Task :generateReleaseBuildConfig

> Task :prepareLintJar

> Task :generateReleaseSources

> Task :javaPreCompileRelease

> Task :mainApkListPersistenceRelease

> Task :generateReleaseResValues

> Task :generateReleaseResources

> Task :mergeReleaseResources

> Task :createReleaseCompatibleScreenManifests

> Task :processReleaseManifest

> Task :processReleaseResources

> Task :compileReleaseJavaWithJavac

> Task :lintVitalRelease

> Task :compileReleaseShaders

> Task :generateReleaseAssets

> Task :mergeReleaseAssets

> Task :validateSigningRelease

> Task :signingConfigWriterRelease

> Task :checkReleaseDuplicateClasses FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.

Use '--warning-mode all' to show the individual deprecation warnings.

See https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings

19 actionable tasks: 19 executed

 

(Luego, repite en un sólo error)

CommandInvokationFailure: Gradle build failed. 
C:/Program Files/Unity/Hub/Editor/2019.2.0b10/Editor/Data/PlaybackEngines/AndroidPlayer/Tools\OpenJDK\Windows\bin\java.exe -classpath "C:\Program Files\Unity\Hub\Editor\2019.2.0b10\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-5.1.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx4096m" "assembleRelease"

stderr[

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':checkReleaseDuplicateClasses'.
> 1 exception was raised by workers:
  java.lang.RuntimeException: Duplicate class com.unity3d.ads.BuildConfig found in modules classes.jar (:UnityAds:) and classes.jar (:unity-ads:)
  Duplicate class com.unity3d.ads.IUnityAdsListener found in modules classes.jar (:UnityAds:) and classes.jar (:unity-ads:)
  Duplicate class com.unity3d.ads.UnityAds found in modules classes.jar (:UnityAds:) and classes.jar (:unity-ads:)
  Duplicate class com.unity3d.ads.UnityAds$FinishState found in modules classes.jar (:UnityAds:) and classes.jar (:unity-ads:)
  Duplicate class com.unity3d.ads.UnityAds$PlacementState found in modules classes.jar (:UnityAds:) and classes.jar (:unity-ads:)
  Duplicate class com.unity3d.ads.UnityAds$UnityAdsError found in modules classes.jar (:UnityAds:) and classes.jar (:unity-ads:)
  Duplicate class com.unity3d.ads.mediation.IUnityAdsExtendedListener found in modules classes.jar (:UnityAds:) and classes.jar (:unity-ads:)
  Duplicate class com.unity3d.ads.metadata.InAppPurchaseMetaData found in modules classes.jar (:UnityAds:) and classes.jar (:unity-ads:)
  Duplicate class com.unity3d.ads.metadata.MediationMetaData found in modules classes.jar (:UnityAds:) and classes.jar (:unity-ads:)
  Duplicate class com.unity3d.ads.metadata.MetaData found in modules classes.jar (:UnityAds:) and classes.jar (:unity-ads:)
  Duplicate class com.unity3d.ads.metadata.PlayerMetaData found in modules classes.jar (:UnityAds:) and classes.jar (:unity-ads:)
  
  Go to the documentation to learn how to Fix dependency resolution errors.


* 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 45s
]
stdout[

> Configure project :
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2019.2.0b10\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\build-tools\28.0.3\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2019.2.0b10\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2019.2.0b10\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-28\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2019.2.0b10\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2019.2.0b10\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\build-tools\28.0.3\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2019.2.0b10\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2019.2.0b10\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-28\package.xml. Probably the SDK is read-only
Exception while marshalling C:\Program Files\Unity\Hub\Editor\2019.2.0b10\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tools\package.xml. Probably the SDK is read-only

> Task :preBuild UP-TO-DATE
> Task :preReleaseBuild
> Task :compileReleaseAidl NO-SOURCE
> Task :compileReleaseRenderscript NO-SOURCE
> Task :checkReleaseManifest
> Task :generateReleaseBuildConfig
> Task :prepareLintJar
> Task :generateReleaseSources
> Task :javaPreCompileRelease
> Task :mainApkListPersistenceRelease
> Task :generateReleaseResValues
> Task :generateReleaseResources
> Task :mergeReleaseResources
> Task :createReleaseCompatibleScreenManifests
> Task :processReleaseManifest
> Task :processReleaseResources
> Task :compileReleaseJavaWithJavac
> Task :compileReleaseSources
> Task :lintVitalRelease
> Task :mergeReleaseShaders
> Task :compileReleaseShaders
> Task :generateReleaseAssets
> Task :mergeReleaseAssets
> Task :validateSigningRelease
> Task :signingConfigWriterRelease
> Task :checkReleaseDuplicateClasses FAILED

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings
19 actionable tasks: 19 executed
]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <8277255796414cc8b8865316c1676de5>:0)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <8277255796414cc8b8865316c1676de5>:0)
UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <8277255796414cc8b8865316c1676de5>:0)
UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1[T] progress, System.String error) (at <8277255796414cc8b8865316c1676de5>:0)
UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1[T] progress) (at <8277255796414cc8b8865316c1676de5>:0)
Rethrow as GradleInvokationException: Gradle build failed
UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action`1[T] progress) (at <8277255796414cc8b8865316c1676de5>:0)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <8277255796414cc8b8865316c1676de5>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <8277255796414cc8b8865316c1676de5>:0)
Rethrow as BuildFailedException: Exception of type 'UnityEditor.Build.BuildFailedException' was thrown.
UnityEditor.Android.PostProcessor.CancelPostProcess.AbortBuild (System.String title, System.String message, System.Exception ex) (at <8277255796414cc8b8865316c1676de5>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <8277255796414cc8b8865316c1676de5>:0)
UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (UnityEditor.BuildTarget target, System.String stagingAreaData, System.String stagingArea, System.String playerPackage, System.String installPath, System.String companyName, System.String productName, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at <8277255796414cc8b8865316c1676de5>:0)
UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <8277255796414cc8b8865316c1676de5>:0)
UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.String installPath, System.String companyName, System.String productName, System.Int32 width, System.Int32 height, UnityEditor.BuildOptions options, UnityEditor.RuntimeClassRegistry usedClassRegistry, UnityEditor.Build.Reporting.BuildReport report) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/PostprocessBuildPlayer.cs:281)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

(Y por último dos errores más)

Build completed with a result of 'Failed'

UnityEditor.BuildPlayerWindow+BuildMethodException: 71 errors
  at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x00242] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:190 
  at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x0007f] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:95 
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
 

Hasta ahora iba solucionando los problemas que me surgían leyendo la consola, indagando y tal, pero tanta información de errores de golpe me suena a chino completamente y no sé por dónde empezar siquiera. Sólo entiendo que hay unas clases duplicadas (Unity-ads, aunque he probado con otro proyecto sin publicidad integrada y también falla, por lo que creo que eso no es el error principal), pero no entiendo qué puedo probar, no sé qué significan las task, o como poner el warning mode, ni el stracktrace ni debug option, ni creo que supiera usarlos aunque supiera ponerlos.

He empezado otro proyecto y le he ido añadiendo cosas que se me ocurre que han podido fallar en los otros, pero siempre me construye la apk sin problemas.

Entonces, mis preguntas son:

-¿Me podéis decir qué está yendo mal, resumiendo todo eso? Porque no lo entiendo...

-Si es debido a haber instalado las SDK tools después de iniciar los proyectos, y por eso en el nuevo construye sin problema, ¿hay alguna manera de solucionar esos errores sin tener que hacer todo desde 0 en un nuevo proyecto?

 

Share this post


Link to post
Share on other sites

El problema está en que hay dos clases llamadas Unity.ads, de seguro instalaste el sdk desde asset Store, pero unity ya tiene uno por defecto, entonces al haber instalado otra, todos LOS MISMOS ARCHIVOS pero en diferentes directorios (carpetas) están que se chocan al compilar, y descuida, no es necesario comenzar de 0, solo trata de eliminar todo el sdk de anuncios que instalaste y prueba, debería funcionar, luego revisa algún tutorial actualizado sobre como instalar anuncios de Unity.

Share this post


Link to post
Share on other sites

Ohh pues miraré eso a ver si se soluciona, gracias! Iré informando

 

Y no, he borrado la carpeta de SDK, lo que lo hace fallar más, o he eliminado la de UnityAds del pryecto, lo que también da errores. Estoy muy perdido en esto, tendré que ir mirando más concienzudamente 

Edited by KaryBlack

Share this post


Link to post
Share on other sites

×
×
  • Create New...