Can't build for Android in Unity 2021.3.16

I changed my project from PC to Android and since then I kept getting various errors when I build.

Error 1:

> 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 :launcher:preBuild UP-TO-DATE

> Task :launcher:preReleaseBuild UP-TO-DATE

> Task :unityLibrary:preBuild UP-TO-DATE

> Task :unityLibrary:preReleaseBuild UP-TO-DATE

> Task :unityLibrary:compileReleaseAidl NO-SOURCE

> Task :launcher:generateReleaseBuildConfig UP-TO-DATE

> Task :launcher:compileReleaseAidl NO-SOURCE

> Task :unityLibrary:packageReleaseRenderscript NO-SOURCE

> Task :unityLibrary:compileReleaseRenderscript NO-SOURCE

> Task :unityLibrary:generateReleaseResValues UP-TO-DATE

> Task :unityLibrary:generateReleaseResources UP-TO-DATE

> Task :unityLibrary:packageReleaseResources UP-TO-DATE

> Task :launcher:javaPreCompileRelease UP-TO-DATE

Task :unityLibrary:extractDeepLinksRelease UP-TO-DATE

> Task :launcher:compileReleaseRenderscript NO-SOURCE

> Task :launcher:generateReleaseResValues UP-TO-DATE

> Task :launcher:generateReleaseResources UP-TO-DATE

> Task :launcher:mergeReleaseResources UP-TO-DATE

> Task :launcher:createReleaseCompatibleScreenManifests UP-TO-DATE

> Task :launcher:extractDeepLinksRelease UP-TO-DATE

> Task :launcher:prepareLintJar UP-TO-DATE

> Task :launcher:checkReleaseDuplicateClasses UP-TO-DATE

> Task :launcher:desugarReleaseFileDependencies UP-TO-DATE

> Task :launcher:mergeExtDexRelease UP-TO-DATE

> Task :launcher:mergeReleaseShaders UP-TO-DATE

> Task :launcher:compileReleaseShaders NO-SOURCE

> Task :launcher:generateReleaseAssets UP-TO-DATE

> Task :launcher:processReleaseJavaRes NO-SOURCE

> Task :launcher:collectReleaseDependencies UP-TO-DATE

> Task :launcher:sdkReleaseDependencyData UP-TO-DATE

> Task :launcher:mergeReleaseJniLibFolders UP-TO-DATE

> Task :launcher:validateSigningRelease UP-TO-DATE

> Task :launcher:validateSigningRelease UP-TO-DATE

> Task :unityLibrary:processReleaseManifest UP-TO-DATE

> Task :unityLibrary:compileReleaseLibraryResources UP-TO-DATE

> Task :unityLibrary:parseReleaseLocalResources UP-TO-DATE

> Task :launcher:processReleaseManifest UP-TO-DATE

> Task :unityLibrary:generateReleaseRFile UP-TO-DATE

> Task :unityLibrary:generateReleaseBuildConfig UP-TO-DATE

> Task :unityLibrary:javaPreCompileRelease UP-TO-DATE

aapt2.exe W 07-23 17:25:26 16596 13440 LoadedArsc.cpp:657] Unknown chunk type ‘200’.

> Task :launcher:processReleaseResources FAILED

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

You can use ‘–warning-mode all’ to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See Command-Line Interface

26 actionable tasks: 1 executed, 25 up-to-date

See Command-Line Interface

Error 2:Preformatted text

BUILD FAILED in 3s

Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8

UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

Error 3:

CommandInvokationFailure: Gradle build failed.

C:\Program Files\Java\jdk1.8.0_77\bin\java.exe -classpath “D:\gradle\gradle-7.6.2\lib\gradle-launcher-7.6.2.jar” org.gradle.launcher.GradleMain “-Dorg.gradle.jvmargs=-Xmx4096m” “assembleRelease”

Environment Variables:

USERDOMAIN = DESKTOP-3SC81PM

ProgramFiles = C:\Program Files

TMP = C:\Users\HP\AppData\Local\Temp

ChocolateyLastPathUpdate = 133333214059136687

PROCESSOR_ARCHITECTURE = AMD64

HEAP_CLIENT_TOKEN_STAGING = 3786794399

PROCESSOR_REVISION = 8e09

OS = Windows_NT

CHROME_CRASHPAD_PIPE_NAME = \.\pipe\crashpad_15268_SRXRRMCVAHEBZZDX

PROCESSOR_IDENTIFIER = Intel64 Family 6 Model 142 Stepping 9, GenuineIntel

AMPLITUDE_API_KEY = 28f3cae0b33b8b3702120c9ed1a935aa

USERPROFILE = C:\Users\HP

JAVA_HOME = C:\Program Files\Java\jdk1.8.0_77

CommonProgramFiles = C:\Program Files\Common Files

DriverData = C:\Windows\System32\Drivers\DriverData

ComSpec = C:\Windows\system32\cmd.exe

LAUNCH_DARKLY_CLIENT_TOKEN = 60a7e30fafc7e60e33446283

PSModulePath = C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules

ANDROID_NDK_ROOT = E:\ndk\android-ndk-r21d

USERNAME = HP

HEAP_CLIENT_TOKEN = 1717415662

NUMBER_OF_PROCESSORS = 4

ZES_ENABLE_SYSMAN = 1

WOOTRIC_CLIENT_TOKEN = NPS-aa8be4c3

JAVA_TOOL_OPTIONS = -Dfile.encoding=UTF-8

DEBUG_ENV_VAR = UnityHub

ProgramW6432 = C:\Program Files

FPS_BROWSER_APP_PROFILE_STRING = Internet Explorer

TEMP = C:\Users\HP\AppData\Local\Temp

Path = C:\Program Files\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files\dotnet;C:\Program Files (x86)\Common Files\Acronis\SnapAPI;C:\Program Files (x86)\dotnet;C:\Program Files\Microsoft SQL Server\150\Tools\Binn;C:\ProgramData\chocolatey\bin;C:\Program Files\Git\cmd;C:\Program

Files\nodejs;C:\Users\HP\AppData\Local\Microsoft\WindowsApps;C:\Users\HP.dotnet\tools;C:\Users\HP\AppData\Local\Programs\Microsoft VS Code\bin;C:\Program Files\Java\jdk1.8.0_77\bin;C:\Dev\flutter\bin;C:\Windows\System32;C:\Users\HP\AppData\Local\Pub\Cache\bin;C:\Users\HP\AppData\Roaming\npm;D:\Firebase_Cmd;D:\scrcpy-win64-v2.1;

COMPUTERNAME = DESKTOP-3SC81PM

BURST_ANDROID_MIN_API_LEVEL = 22

PATHEXT = .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

SystemDrive = C:

ALLUSERSPROFILE = C:\ProgramData

SENTRY_ACCESS_TOKEN = 3df78d9e53f8456aa90fbae044ce1a6261421ab1d0014674bc2e933477289017

ChocolateyInstall = C:\ProgramData\chocolatey

FPS_BROWSER_USER_PROFILE_STRING = Default

windir = C:\Windows

AMPLITUDE_API_KEY_STAGING = 83ee04fccc67e4fcc7dd527c4c6f1e21

PUBLIC = C:\Users\Public

CommonProgramFiles(x86) = C:\Program Files (x86)\Common Files

APPDATA = C:\Users\HP\AppData\Roaming

OneDrive = C:\Users\HP\OneDrive

PROCESSOR_LEVEL = 6

CommonProgramW6432 = C:\Program Files\Common Files

ProgramFiles(x86) = C:\Program Files (x86)

SystemRoot = C:\Windows

SESSIONNAME = Console

LOGONSERVER = \DESKTOP-3SC81PM

LOCALAPPDATA = C:\Users\HP\AppData\Local

HOMEPATH = \Users\HP

LAUNCH_DARKLY_CLIENT_TOKEN_STAGING = 60a7e30fafc7e60e33446282

HOMEDRIVE = C:

USERDOMAIN_ROAMINGPROFILE = DESKTOP-3SC81PM

ProgramData = C:\ProgramData

ORIGINAL_XDG_CURRENT_DESKTOP = undefined

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.


  • What went wrong:

Execution failed for task ‘:unityLibrary:compileReleaseJavaWithJavac’. > Failed to calculate the value of task ‘:unityLibrary:compileReleaseJavaWithJavac’ property ‘options.generatedSourceOutputDirectory’. > Querying the mapped value of map(java.io.File property(org.gradle.api.file.Directory, fixed(class org.gradle.api.internal.file.DefaultFilePropertyFactory$FixedDirectory, E:\SlidingPuzzle-main Phone\Library\Bee\Android\Prj\IL2CPP\Gradle\unityLibrary\build\generated\ap_generated_sources\release\out)) org.gradle.api.internal.file.DefaultFilePropertyFactory$ToFileTransformer@5d7a5e33) before task ‘:unityLibrary:compileReleaseJavaWithJavac’ has completed is not supported * 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. ============================================================================== 2: Task failed with an exception. ----------- * What went wrong: Execution failed for task ‘:launcher:processReleaseResources’. > java.lang.ClassCastException@2117cd5e * 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 3s Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 ] stdout[ > 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 :launcher:preBuild UP-TO-DATE > Task :launcher:preReleaseBuild UP-TO-DATE > Task :unityLibrary:preBuild UP-TO-DATE > Task :unityLibrary:preReleaseBuild UP-TO-DATE > Task :unityLibrary:compileReleaseAidl NO-SOURCE > Task :launcher:generateReleaseBuildConfig UP-TO-DATE > Task :launcher:compileReleaseAidl NO-SOURCE > Task :unityLibrary:packageReleaseRenderscript NO-SOURCE > Task :unityLibrary:compileReleaseRenderscript NO-SOURCE > Task :unityLibrary:generateReleaseResValues UP-TO-DATE > Task :unityLibrary:generateReleaseResources UP-TO-DATE > Task :unityLibrary:packageReleaseResources UP-TO-DATE > Task :launcher:javaPreCompileRelease UP-TO-DATE > Task :unityLibrary:extractDeepLinksRelease UP-TO-DATE > Task :launcher:compileReleaseRenderscript NO-SOURCE > Task :launcher:generateReleaseResValues UP-TO-DATE > Task :launcher:generateReleaseResources UP-TO-DATE > Task :launcher:mergeReleaseResources UP-TO-DATE > Task :launcher:createReleaseCompatibleScreenManifests UP-TO-DATE > Task :launcher:extractDeepLinksRelease UP-TO-DATE > Task :launcher:prepareLintJar UP-TO-DATE > Task :launcher:checkReleaseDuplicateClasses UP-TO-DATE > Task :launcher:desugarReleaseFileDependencies UP-TO-DATE > Task :launcher:mergeExtDexRelease UP-TO-DATE > Task :launcher:mergeReleaseShaders UP-TO-DATE > Task :launcher:compileReleaseShaders NO-SOURCE > Task :launcher:generateReleaseAssets UP-TO-DATE > Task :launcher:processReleaseJavaRes NO-SOURCE > Task :launcher:collectReleaseDependencies UP-TO-DATE > Task :launcher:sdkReleaseDependencyData UP-TO-DATE > Task :launcher:mergeReleaseJniLibFolders UP-TO-DATE > Task :launcher:validateSigningRelease UP-TO-DATE > Task :unityLibrary:processReleaseManifest UP-TO-DATE > Task :unityLibrary:compileReleaseLibraryResources UP-TO-DATE > Task :unityLibrary:parseReleaseLocalResources UP-TO-DATE > Task :launcher:processReleaseManifest UP-TO-DATE > Task :unityLibrary:generateReleaseRFile UP-TO-DATE > Task :unityLibrary:generateReleaseBuildConfig UP-TO-DATE > Task :unityLibrary:javaPreCompileRelease UP-TO-DATE aapt2.exe W 07-23 17:25:26 16596 13440 LoadedArsc.cpp:657] Unknown chunk type ‘200’. > Task :launcher:processReleaseResources FAILED Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0. You can use ‘–warning-mode all’ to show the individual deprecation warnings and determine if they come from your own scripts or plugins. See Command-Line Interface 26 actionable tasks: 1 executed, 25 up-to-date ] exit code: 1 UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <62de111f18d242d586f9a078a33b1ba2>:0) UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <62de111f18d242d586f9a078a33b1ba2>:0) UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit,System.String errorMsg) (at <62de111f18d242d586f9a078a33b1ba2>:0) UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action1[T] progress, System.String error) (at <62de111f18d242d586f9a078a33b1ba2>: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 <62de111f18d242d586f9a078a33b1ba2>: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 <62de111f18d242d586f9a078a33b1ba2>:0) UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <62de111f18d242d586f9a078a33b1ba2>:0) UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <62de111f18d242d586f9a078a33b1ba2>: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 <62de111f18d242d586f9a078a33b1ba2>:0) UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <62de111f18d242d586f9a078a33b1ba2>:0) UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, AndroidPlayerBuildProgram.Data.AndroidPlayerBuildProgramOutput buildProgramOutput) (at <62de111f18d242d586f9a078a33b1ba2>:0) UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <62de111f18d242d586f9a078a33b1ba2>: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 <11d97693183d4a6bb35c29ae7882c66b>:0) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

There were many errors before the final ones I shared above and the solution included removing JCenter and added mavenCentral instead. Here is my gradle template:

I have this line in the gradle properties and when I remove it unity gives me a message I provided a screenshot.
Sorry if I put unnecessary stuff I am not sure which one you need to help me.
I really appreciate any help you can provide.

android.enableR8=**MINIFY_WITH_R_EIGHT**

allprojects {
    buildscript {
         ext.kotlin_version = '1.6.10'
        repositories {**ARTIFACTORYREPOSITORY**
            google()
        
              mavenCentral()
              gradlePluginPortal()
        }

        dependencies {
            // If you are changing the Android Gradle Plugin version, make sure it is compatible with the Gradle version preinstalled with Unity
            // See which Gradle version is preinstalled with Unity here https://docs.unity3d.com/Manual/android-gradle-overview.html
            // See official Gradle and Android Gradle Plugin compatibility table here https://developer.android.com/studio/releases/gradle-plugin#updating-gradle
            // To specify a custom Gradle version in Unity, go do "Preferences > External Tools", uncheck "Gradle Installed with Unity (recommended)" and specify a path to a custom Gradle version
            classpath 'com.android.tools.build:gradle:4.0.1'
            **BUILD_SCRIPT_DEPS**
        }
    }

    
    repositories {**ARTIFACTORYREPOSITORY**
        google()
        mavenCentral()
        flatDir {
            dirs "${project(':unityLibrary').projectDir}/libs"
        }
    }
}



task clean(type: Delete) {
    delete rootProject.buildDir
}

If i recall, this is deprecated, as the error is telling you in the final screenshot. Allow unity to automatically update this file, a backup will be created if there is anything in there you need to reference later.

1 Like

Thanks for replying, Yes, it’s deprecated, I don’t know how to stop getting this message because when I remove that line Unity adds it again. This error doesn’t seem to have caused the major build error though, because I remember I had this error before and it was not big of a deal other than being an annoying error message.