androidunity-game-engineapkmapbox

Mapbox SDK breaks Unity build with Could not resolve all files for configuration ':launcher:releaseRuntimeClasspath'


When adding Unity mapbox sdk to blank project I am unable to build an apk of the project

I've tried following a few tutorials online/youtube but each time I add mapbox my builds start failing, trying to debug this I took it back to the beginning and tried the following: If I create a blank project in unity version: 2022.3.39f1 Change platform to android set minimum api to 33 scripting backend to ILC2PP include ARM64 import the latest unity mapbox SDK version: 2.1.1 (trying to reduce clutter i import only Mapbox and third party assets)

Note: per one suggestion I saw I have also tried ticking the boxes for Custom Main Gradle Template & Custom Gradle Properties Template then when I try to build the project I get the above error, it then tells me to check the console for more details

For completeness the logs are (having stripped out some values):

Could not resolve all files for configuration ':launcher:releaseRuntimeClasspath'. Failed to transform support-v4-25.1.0-.aar (:support-v4-25.1.0:) to match attributes {artifactType=enumerated-runtime-classes, org.gradle.status=integration, org.gradle.usage=java-runtime}. > Execution failed for JetifyTransform: /Users/adamjones/today/Library/Bee/Android/Prj/IL2CPP/Gradle/unityLibrary/libs/support-v4-25.1.0.aar. > Failed to transform '/Users/adamjones/today/Library/Bee/Android/Prj/IL2CPP/Gradle/unityLibrary/libs/support-v4-25.1.0.aar' using Jetifier. Reason: AmbiguousStringJetifierException, message: The given artifact contains a string literal with a package reference 'android.support.v4' that cannot be safely rewritten. Libraries using reflection such as annotation processors need to be updated manually to add support for androidx.. (Run with --stacktrace for more details.) This is a known exception, and Jetifier won't be able to jetify this library. Suggestions: - If you believe this library doesn't need to be jetified (e.g., if it already supports AndroidX, or if it doesn't use support libraries/AndroidX at all), add android.jetifier.ignorelist = {comma-separated list of regular expressions (or simply names) of the libraries that you don't want to be jetified} to the gradle.properties file. - If you believe this library needs to be jetified (e.g., if it uses old support libraries and breaks your app if it isn't jetified), contact the library's authors to update this library to support AndroidX and use the supported version once it is released. If you need further help, please leave a comment at https://issuetracker.google.com/issues/140747218.

==============================================================================

2: Task failed with an exception. java.lang.StackOverflowError (no error message)

Get more help at https://help.gradle.org

BUILD FAILED in 2s WARNING:We recommend using a newer Android Gradle plugin to use compileSdk = 34

This Android Gradle plugin (7.4.2) was tested up to compileSdk = 33

This warning can be suppressed by adding android.suppressUnsupportedCompileSdk=34 to this project's gradle.properties

The build will continue, but you are strongly encouraged to update your project to use a newer Android Gradle Plugin that has been tested with compileSdk = 34 Task :unityLibrary:preBuild UP-TO-DATE Task :unityLibrary:preReleaseBuild UP-TO-DATE Task :launcher:preBuild UP-TO-DATE Task :unityLibrary:compileReleaseAidl NO-SOURCE Task :launcher:preReleaseBuild UP-TO-DATE Task :launcher:compileReleaseAidl NO-SOURCE Task :launcher:generateReleaseBuildConfig UP-TO-DATE Task :unityLibrary:mergeReleaseJniLibFolders UP-TO-DATE Task :launcher:javaPreCompileRelease UP-TO-DATE Task :unityLibrary:mergeReleaseNativeLibs UP-TO-DATE Task :launcher:generateReleaseResValues UP-TO-DATE Task :unityLibrary:stripReleaseDebugSymbols UP-TO-DATE Task :launcher:createReleaseCompatibleScreenManifests UP-TO-DATE Task :launcher:extractProguardFiles UP-TO-DATE Task :launcher:mergeReleaseJniLibFolders UP-TO-DATE Task :launcher:checkReleaseDuplicateClasses FAILED Task :unityLibrary:copyReleaseJniLibsProjectAndLocalJars 11 actionable tasks: 2 executed, 9 up-to-date ] exit code: 1 UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <8b08da1c605e437b9a4d35d57a5bb352>:0) UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <8b08da1c605e437b9a4d35d57a5bb352>:0) UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <8b08da1c605e437b9a4d35d57a5bb352>:0) UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action1[T] progress, System.String error) (at <8b08da1c605e437b9a4d35d57a5bb352>:0) UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, Unity.Android.Gradle.AndroidGradle androidGradle, System.String workingdir, System.String task, System.Action1[T] progress) (at <8b08da1c605e437b9a4d35d57a5bb352>: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 <8b08da1c605e437b9a4d35d57a5bb352>:0) UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <8b08da1c605e437b9a4d35d57a5bb352>:0) UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <8b08da1c605e437b9a4d35d57a5bb352>:0) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&) (at /Users/bokken/build/output/unity/unity/Modules/IMGUI/GUIUtility.cs:203)

Given how widely used the sdk is i find it hard to believe the issue isn't something I have done wrong, but the indication there is duplicate classes is hard to believe when it is an empty project

has anyone had a similar issue or is able to better interpret the error / highlight what I have done wrong?


Solution

  • I had the same issue today with an older version of MapBox.

    [Update]

    It looks like is some conflict between mapbox plugin and Unity.

    I tried to run jetifier-standalone to generate a new .aar but dos'nt work, i delete all .aar from Assets\Mapbox\Core\Plugins and built.

    I not tested in android yet.