Search Unity

Bug Constant version-nonspecific Android Gradle build error

Discussion in 'Editor & General Support' started by Rose932, Jun 28, 2022.

  1. Rose932

    Rose932

    Joined:
    May 22, 2021
    Posts:
    5
    Myself & my co-developer have been experiencing a non-stop error when trying to build for Android with our project, for the past month and a half. It has persisted across a Unity update, a Unity downgrade (which we reverted after it did not fix the error) and a multitude of tests, up to and including exporting the project and trying to build it with Android Studio. We're looking for a solution, our only possible alternative at this point is to try and migrate to a new unity project.

    It appears that the issue is something along the lines of

    Gradle Build Error

    Failed to execute :mergeNativeLibs

    OR

    Gradle Build Error

    Failed to execute :releaseNativeLibs



    This is not an exact copy, as building takes a long time due to this being an XR project. However, I can build and have an actual copy of the error if requested.
    Does anyone have a similar issue, and if so, do you know a concrete fix?

    This is also an extremely urgent issue for me, as we have a major release coming up shortly and while I can release without an android build I would strongly like to avoid it, same with migrating the project.

    Project information:
    Unity 2021.3.2f1
    Universal Render Pipeline

    My sincere apologies if this is the wrong place for this thread, but I'm running out of options.
     
    Last edited: Jun 28, 2022
    anycolourulike likes this.
  2. Rose932

    Rose932

    Joined:
    May 22, 2021
    Posts:
    5
    Update - here is a full copy of the Gradle error. I am unsure as to how to continue.
    Sorry to dump an entire stack trace, but I don't know how else to convey the issue.


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

    stderr[
    Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
    Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/03 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/03 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/03 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
    Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
    Warning: unexpected element (uri:"", local:"base-extension"). Expected elements are <{}codename>,<{}layoutlib>,<{}api-level>
    Note: C:\Unity Projects\Compensation VR\Library\Bee\Android\Prj\IL2CPP\Gradle\unityLibrary\src\main\java\com\unity3d\player\UnityPlayerActivity.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.

    FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ':launcher:mergeReleaseNativeLibs'.
    > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
    > More than one file was found with OS independent path 'lib/arm64-v8a/libopenxr_loader.so'. If you are using jniLibs and CMake IMPORTED targets, see https://developer.android.com/studio/preview/features#automatic_packaging_of_prebuilt_dependencies_used_by_cmake

    * 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 41s
    Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
    ]
    stdout[
    Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details

    > Configure project :launcher
    WARNING: The option setting 'android.enableR8=false' is deprecated.
    It will be removed in version 5.0 of the Android Gradle plugin.
    You will no longer be able to disable R8

    > Task :unityLibrary:preBuild UP-TO-DATE
    > Task :launcher:preBuild UP-TO-DATE
    > Task :launcher:preReleaseBuild UP-TO-DATE
    > Task :unityLibrary:preReleaseBuild UP-TO-DATE
    > Task :unityLibrary:compileReleaseAidl NO-SOURCE
    > Task :unityLibrary:packageReleaseRenderscript NO-SOURCE
    > Task :unityLibrary:compileReleaseRenderscript NO-SOURCE
    > Task :unityLibrary:generateReleaseResValues
    > Task :unityLibrary:generateReleaseResources
    > Task :launcher:generateReleaseBuildConfig
    > Task :launcher:compileReleaseAidl NO-SOURCE
    > Task :launcher:compileReleaseRenderscript NO-SOURCE
    > Task :launcher:generateReleaseResValues
    > Task :launcher:generateReleaseResources
    > Task :launcher:createReleaseCompatibleScreenManifests
    > Task :launcher:extractDeepLinksRelease
    > Task :launcher:javaPreCompileRelease
    > Task :launcher:prepareLintJar
    > Task :unityLibrary:packageReleaseResources
    > Task :unityLibrary:extractDeepLinksRelease
    > Task :launcher:checkReleaseDuplicateClasses
    > Task :launcher:mergeReleaseShaders
    > Task :launcher:compileReleaseShaders NO-SOURCE
    > Task :launcher:generateReleaseAssets UP-TO-DATE
    > Task :launcher:processReleaseJavaRes NO-SOURCE
    > Task :launcher:collectReleaseDependencies
    > Task :launcher:sdkReleaseDependencyData
    > Task :launcher:mergeReleaseJniLibFolders
    > Task :launcher:validateSigningRelease
    > Task :launcher:mergeReleaseResources
    > Task :unityLibrary:generateReleaseBuildConfig
    > Task :unityLibrary:mergeReleaseShaders
    > Task :unityLibrary:compileReleaseShaders NO-SOURCE
    > Task :unityLibrary:generateReleaseAssets UP-TO-DATE
    > Task :unityLibrary:prepareLintJarForPublish
    > Task :launcher:desugarReleaseFileDependencies
    > Task :launcher:mergeExtDexRelease
    > Task :unityLibrary:packageReleaseAssets
    > Task :unityLibrary:processReleaseJavaRes NO-SOURCE
    > Task :unityLibrary:bundleLibResRelease NO-SOURCE
    > Task :unityLibrary:mergeReleaseJniLibFolders
    > Task :unityLibrary:processReleaseManifest
    > Task :unityLibrary:javaPreCompileRelease
    > Task :unityLibrary:parseReleaseLocalResources
    > Task :unityLibrary:compileReleaseLibraryResources
    > Task :unityLibrary:mergeReleaseNativeLibs
    > Task :unityLibrary:stripReleaseDebugSymbols
    > Task :launcher:mergeReleaseAssets
    > Task :unityLibrary:copyReleaseJniLibsProjectOnly
    > Task :unityLibrary:generateReleaseRFile
    > Task :launcher:processReleaseManifest
    > Task :launcher:processReleaseResources
    > Task :launcher:mergeReleaseJavaResource
    > Task :launcher:mergeReleaseNativeLibs FAILED

    > Task :unityLibrary:compileReleaseJavaWithJavac
    37 actionable tasks: 37 executed
    ]
    exit code: 1
    UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <cf82a25f0a8443eb910fd35454292555>:0)
    UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <cf82a25f0a8443eb910fd35454292555>:0)
    UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <cf82a25f0a8443eb910fd35454292555>:0)
    UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1[T] progress, System.String error) (at <cf82a25f0a8443eb910fd35454292555>:0)
    UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, Unity.Android.Gradle.AndroidGradle androidGradle, System.String workingdir, System.String task, System.Action`1[T] progress) (at <cf82a25f0a8443eb910fd35454292555>:0)
    Rethrow as GradleInvokationException: Gradle build failed
    UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, Unity.Android.Gradle.AndroidGradle androidGradle, System.String workingdir, System.String task, System.Action`1[T] progress) (at <cf82a25f0a8443eb910fd35454292555>:0)
    Rethrow as GradleInvokationException: Gradle build failed
    UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, Unity.Android.Gradle.AndroidGradle androidGradle, System.String workingdir, System.String task, System.Action`1[T] progress) (at <cf82a25f0a8443eb910fd35454292555>:0)
    UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <cf82a25f0a8443eb910fd35454292555>:0)
    UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <cf82a25f0a8443eb910fd35454292555>: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 <cf82a25f0a8443eb910fd35454292555>:0)
    UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <cf82a25f0a8443eb910fd35454292555>:0)
    UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, AndroidPlayerBuildProgram.Data.AndroidPlayerBuildProgramOutput buildProgramOutput) (at <cf82a25f0a8443eb910fd35454292555>:0)
    UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <cf82a25f0a8443eb910fd35454292555>:0)
    UnityEditor.PostprocessBuildPlayer.Postprocess (UnityEditor.BuildTargetGroup targetGroup, UnityEditor.BuildTarget target, System.Int32 subtarget, 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 <a017e354f3154926a5617fbac3a64fcc>:0)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr, Boolean&)
     
  3. Rose932

    Rose932

    Joined:
    May 22, 2021
    Posts:
    5
    Update: It is an issue with IL2CPP somewhere, I attempted a build with Mono and it built successfully. However, due to platform restrictions, I am forced to use IL2CPP. I am looking into what causes this issue, still.
     
    anycolourulike likes this.
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,692
    Android build not building:

    First, make a blank project with a single blank scene and prove that it builds successfully.

    If it does NOT build, then go fix your Unity installation, or your other tools, such as Android SDK, NDK, JDK, etc.

    Until you can build a blank project to the target platform, don't fiddle with anything else.

    Once you can build a blank project, now bisect the problem by bringing over parts of your current project and building it one subsystem at a time, perhaps stubbing things out that might trigger compiler errors.

    Most often things that prevent building are third-party libraries such as Firebase.

    Once you identify the subsystem, go to the documentation for it and make sure you are doing it correctly.

    It may also be helpful to work through a tutorial or two for that subsystem.
     
  5. Rose932

    Rose932

    Joined:
    May 22, 2021
    Posts:
    5
    Hello, sorry for the late update, in my case it was that both the Open XR Oculus Quest Support and the Oculus Integration Package were both active at the same time, causing a library duplication. Thank you for your time.
     
    choudaniel3 and anycolourulike like this.