Build failure for mapbox example

Hello, all!
I have built some applications on unity and without any problems and now I am trying to build mapbox example (Traffic and Direction) as an android application but I am getting this error
5225537--520937--upload_2019-11-29_1-40-7.png
I checked the number minSdkVersion in the file specified and it is equal to 24
5225537--520940--upload_2019-11-29_1-41-39.png
and tried to edit it and rebuild the scene but the same error pops again
and I uninstall Android SDK and install it again, but the build fails again
Here is the commands in console

CommandInvokationFailure: Gradle build failed.
C:/Program Files/Java/jdk1.8.0_211\bin\java.exe -classpath “C:\Program Files\Unity\Hub\Editor\2018.4.9f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-5.1.1.jar” org.gradle.launcher.GradleMain “-Dorg.gradle.jvmargs=-Xmx4096m” “assembleRelease”

stderr[
D:\grad\androidapp\Temp\gradleOut\src\main\AndroidManifest.xml Error:
uses-sdk:minSdkVersion 16 cannot be smaller than version 24 declared in library [:com.mapbox.android.unity-debug:] C:\Users\USER.gradle\caches\transforms-2\files-2.1\94a1c2f736d85c0b5b621cc7908de2dd\AndroidManifest.xml as the library might be using APIs not available in 16
Suggestion: use a compatible library with a minSdk of at most 16,
or increase this project’s minSdk version to at least 24,
or use tools:overrideLibrary=“com.mapbox.android.unity” to force usage (may lead to runtime failures)

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:processReleaseManifest’.

Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 24 declared in library [:com.mapbox.android.unity-debug:] C:\Users\USER.gradle\caches\transforms-2\files-2.1\94a1c2f736d85c0b5b621cc7908de2dd\AndroidManifest.xml as the library might be using APIs not available in 16
Suggestion: use a compatible library with a minSdk of at most 16,
or increase this project’s minSdk version to at least 24,
or use tools:overrideLibrary=“com.mapbox.android.unity” to force usage (may lead to runtime failures)

  • 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 2m 44s
]
stdout[

Task :preBuild UP-TO-DATE
Task :preReleaseBuild
Task :compileReleaseAidl NO-SOURCE
Task :compileReleaseRenderscript NO-SOURCE
Task :checkReleaseManifest UP-TO-DATE
Task :generateReleaseBuildConfig UP-TO-DATE
Task :prepareLintJar UP-TO-DATE
Task :generateReleaseSources UP-TO-DATE
Task :javaPreCompileRelease
Task :mainApkListPersistenceRelease UP-TO-DATE
Task :generateReleaseResValues UP-TO-DATE
Task :generateReleaseResources UP-TO-DATE
Task :mergeReleaseResources
Task :createReleaseCompatibleScreenManifests UP-TO-DATE

Task :processReleaseManifest FAILED

See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.

10 actionable tasks: 4 executed, 6 up-to-date
]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at :0)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at :0)
UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at :0)
UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action1[T] progress, System.String error) (at <df45ca7b334d4b918976307f9d26db2e>:0) UnityEditor.Android.GradleWrapper.Run (UnityEditor.Android.AndroidJavaTools javaTools, System.String workingdir, System.String task, System.Action1[T] progress) (at :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 :0)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at :0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at :0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

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

Any help will be appreciated

I solved this by changing the minimum API Level in my project settings.
In Unity : EditProject SettingsPlayerOther SettingsMinimum API Level → change it to Android 7.0 (API Level 24).

3 Likes