Android Build Error with empty project.

Hi, I have a trouble with building Unity.

I also reinstalled Unity Hub and its editors (also deleted C:/ProgramFiles/Unity and UnityHub files
User/AppData/ Local, LocalLow, Roaming and User/.gradle/caches before reinstall.)

My editor version is 2021.3.8f1
Unity Hub is 3.2.0

I created empty project and after changing platform to Android, I tried “build and run” to my galaxy 32A.
But the following still occurs and I don’t know how to resolve the problems.
I also checked that in other desktops, Unity app is built successfully, so my phone may not be a reason.

Any help would be appreciated.

Here are detailed error messages.

  1. warning

Unable to find player assembly: C:\UnityProject\My project\Temp\StagingArea\Data\Managed\UnityEngine.TestRunner.dll
UnityEngine.Debug:LogWarning (object)
Unity.Burst.Editor.BurstAotCompiler:OnPostBuildPlayerScriptDLLsImpl (UnityEditor.Build.Reporting.BuildReport) (at Library/PackageCache/com.unity.burst@1.6.6/Editor/BurstAotCompiler.cs:350)
Unity.Burst.Editor.BurstAotCompiler:OnPostBuildPlayerScriptDLLs (UnityEditor.Build.Reporting.BuildReport) (at Library/PackageCache/com.unity.burst@1.6.6/Editor/BurstAotCompiler.cs:208)
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun ()

  1. Starting a Gradle Daemon, 1 incompatible and 2 stopped Daemons 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 :launcher:preBuild UP-TO-DATE
Task :unityLibrary: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 UP-TO-DATE
Task :launcher:generateReleaseBuildConfig UP-TO-DATE
Task :unityLibrary:generateReleaseResources UP-TO-DATE
Task :launcher:compileReleaseAidl NO-SOURCE
Task :launcher:compileReleaseRenderscript NO-SOURCE
Task :launcher:javaPreCompileRelease UP-TO-DATE
Task :launcher:generateReleaseResValues UP-TO-DATE
Task :launcher:generateReleaseResources UP-TO-DATE
Task :launcher:createReleaseCompatibleScreenManifests UP-TO-DATE
Task :unityLibrary:packageReleaseResources UP-TO-DATE
Task :launcher:extractDeepLinksRelease UP-TO-DATE
Task :unityLibrary:extractDeepLinksRelease UP-TO-DATE
Task :unityLibrary:processReleaseManifest UP-TO-DATE
Task :launcher:mergeReleaseResources UP-TO-DATE
Task :unityLibrary:compileReleaseLibraryResources UP-TO-DATE
Task :launcher:processReleaseManifest UP-TO-DATE
Task :launcher:prepareLintJar UP-TO-DATE
Task :unityLibrary:parseReleaseLocalResources UP-TO-DATE
Task :launcher:checkReleaseDuplicateClasses UP-TO-DATE
Task :launcher:desugarReleaseFileDependencies UP-TO-DATE
Task :unityLibrary:generateReleaseRFile UP-TO-DATE
Task :launcher:mergeExtDexRelease UP-TO-DATE
Task :unityLibrary:generateReleaseBuildConfig UP-TO-DATE
Task :unityLibrary:javaPreCompileRelease UP-TO-DATE
Task :launcher:processReleaseResources UP-TO-DATE
Task :launcher:mergeReleaseShaders UP-TO-DATE
Task :launcher:compileReleaseShaders NO-SOURCE
Task :launcher:generateReleaseAssets UP-TO-DATE
Task :unityLibrary:compileReleaseJavaWithJavac UP-TO-DATE
Task :launcher:processReleaseJavaRes NO-SOURCE
Task :unityLibrary:bundleLibCompileToJarRelease UP-TO-DATE
Task :launcher:collectReleaseDependencies UP-TO-DATE
Task :unityLibrary:prepareLintJarForPublish UP-TO-DATE
Task :unityLibrary:bundleLibRuntimeToJarRelease UP-TO-DATE
Task :unityLibrary:mergeReleaseShaders UP-TO-DATE
Task :launcher:compileReleaseJavaWithJavac UP-TO-DATE
Task :launcher:compileReleaseSources UP-TO-DATE
Task :unityLibrary:compileReleaseShaders NO-SOURCE
Task :unityLibrary:generateReleaseAssets UP-TO-DATE
Task :unityLibrary:packageReleaseAssets
Task :unityLibrary:processReleaseJavaRes NO-SOURCE
Task :unityLibrary:bundleLibResRelease NO-SOURCE
Task :unityLibrary:mergeReleaseJniLibFolders
Task :unityLibrary:mergeReleaseNativeLibs
Task :unityLibrary:stripReleaseDebugSymbols
Task :unityLibrary:copyReleaseJniLibsProjectOnly
Task :launcher:lintVitalRelease
Task :launcher:dexBuilderRelease UP-TO-DATE
Task :launcher:mergeDexRelease UP-TO-DATE
Task :launcher:mergeReleaseAssets
Task :launcher:mergeReleaseJavaResource UP-TO-DATE
Task :launcher:sdkReleaseDependencyData UP-TO-DATE
Task :launcher:mergeReleaseJniLibFolders UP-TO-DATE
Task :launcher:validateSigningRelease UP-TO-DATE
Task :launcher:mergeReleaseNativeLibs
Task :launcher:stripReleaseDebugSymbols
Task :launcher:packageRelease FAILED
45 actionable tasks: 10 executed, 35 up-to-date

UnityEditor.BuildPlayerWindow:BuildPlayerAndRun ()

  1. FAILURE: Build failed with an exception.
  • What went wrong:
    Execution failed for task ‘:launcher:packageRelease’.

A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
com.android.ide.common.signing.KeytoolException: Failed to read key AndroidDebugKey from store “C:\Users\USER1.android\debug.keystore”: Invalid keystore format

  • 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 10s
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8

UnityEditor.BuildPlayerWindow:BuildPlayerAndRun ()

  1. CommandInvokationFailure: Gradle build failed.

C:\ProgramFiles\Unity\Hub\Editor\2021.3.8f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath “C:\Program Files\Unity\Hub\Editor\2021.3.8f1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-6.1.1.jar” org.gradle.launcher.GradleMain “-Dorg.gradle.jvmargs=-Xmx4096m” “assembleRelease”

Environment Variables:
USERDOMAIN = DESKTOP-KQSHQGC
ProgramFiles = C:\Program Files
TMP = C:\Users\USER1\AppData\Local\Temp
PROCESSOR_ARCHITECTURE = AMD64
PROCESSOR_REVISION = 9e0a
OS = Windows_NT
ALLUSERSPROFILE = C:\ProgramData
PROCESSOR_IDENTIFIER = Intel64 Family 6 Model 158 Stepping 10, GenuineIntel
ProgramW6432 = C:\Program Files
JAVA_TOOL_OPTIONS = -Dfile.encoding=UTF-8
USERPROFILE = C:\Users\USER1
JAVA_HOME = C:\Program Files\Unity\Hub\Editor\2021.3.8f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK
CommonProgramFiles = C:\Program Files\Common Files
DriverData = C:\Windows\System32\Drivers\DriverData
ComSpec = C:\Windows\system32\cmd.exe
PSModulePath = C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
ANDROID_NDK_ROOT = C:\Program Files\Unity\Hub\Editor\2021.3.8f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK
USERNAME = USER1
NUMBER_OF_PROCESSORS = 6
ORIGINAL_XDG_CURRENT_DESKTOP = undefined
TEMP = C:\Users\USER1\AppData\Local\Temp
Path = C:\Program Files\Eclipse Foundation\jdk-8.0.302.8-hotspot\bin;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\Microsoft SQL Server\130\Tools\Binn;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn;C:\Users\USER1\AppData\Local\Microsoft\WindowsApps;C:\Users\USER1\AppData\Local\gitkraken\bin;C:\Users\USER1.dotnet\tools
COMPUTERNAME = DESKTOP-KQSHQGC
PATHEXT = .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
SystemDrive = C:
windir = C:\Windows
HOMEPATH = \Users\USER1
PUBLIC = C:\Users\Public
CommonProgramFiles(x86) = C:\Program Files (x86)\Common Files
APPDATA = C:\Users\USER1\AppData\Roaming
OneDrive = C:\Users\USER1\OneDrive
PROCESSOR_LEVEL = 6
CommonProgramW6432 = C:\Program Files\Common Files
ProgramFiles(x86) = C:\Program Files (x86)
SystemRoot = C:\Windows
LOGONSERVER = \DESKTOP-KQSHQGC
LOCALAPPDATA = C:\Users\USER1\AppData\Local
HOMEDRIVE = C:
USERDOMAIN_ROAMINGPROFILE = DESKTOP-KQSHQGC
ProgramData = C:\ProgramData
BURST_ANDROID_MIN_API_LEVEL = 22

stderr[

FAILURE: Build failed with an exception.

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

A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
com.android.ide.common.signing.KeytoolException: Failed to read key AndroidDebugKey from store “C:\Users\USER1.android\debug.keystore”: Invalid keystore format

  • 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 10s
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
]
stdout[
Starting a Gradle Daemon, 1 incompatible and 2 stopped Daemons 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 :launcher:preBuild UP-TO-DATE
Task :unityLibrary: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 UP-TO-DATE
Task :launcher:generateReleaseBuildConfig UP-TO-DATE
Task :unityLibrary:generateReleaseResources UP-TO-DATE
Task :launcher:compileReleaseAidl NO-SOURCE
Task :launcher:compileReleaseRenderscript NO-SOURCE
Task :launcher:javaPreCompileRelease UP-TO-DATE
Task :launcher:generateReleaseResValues UP-TO-DATE
Task :launcher:generateReleaseResources UP-TO-DATE
Task :launcher:createReleaseCompatibleScreenManifests UP-TO-DATE
Task :unityLibrary:packageReleaseResources UP-TO-DATE
Task :launcher:extractDeepLinksRelease UP-TO-DATE
Task :unityLibrary:extractDeepLinksRelease UP-TO-DATE
Task :unityLibrary:processReleaseManifest UP-TO-DATE
Task :launcher:mergeReleaseResources UP-TO-DATE
Task :unityLibrary:compileReleaseLibraryResources UP-TO-DATE
Task :launcher:processReleaseManifest UP-TO-DATE
Task :launcher:prepareLintJar UP-TO-DATE
Task :unityLibrary:parseReleaseLocalResources UP-TO-DATE
Task :launcher:checkReleaseDuplicateClasses UP-TO-DATE
Task :launcher:desugarReleaseFileDependencies UP-TO-DATE
Task :unityLibrary:generateReleaseRFile UP-TO-DATE
Task :launcher:mergeExtDexRelease UP-TO-DATE
Task :unityLibrary:generateReleaseBuildConfig UP-TO-DATE
Task :unityLibrary:javaPreCompileRelease UP-TO-DATE
Task :launcher:processReleaseResources UP-TO-DATE
Task :launcher:mergeReleaseShaders UP-TO-DATE
Task :launcher:compileReleaseShaders NO-SOURCE
Task :launcher:generateReleaseAssets UP-TO-DATE
Task :unityLibrary:compileReleaseJavaWithJavac UP-TO-DATE
Task :launcher:processReleaseJavaRes NO-SOURCE
Task :unityLibrary:bundleLibCompileToJarRelease UP-TO-DATE
Task :launcher:collectReleaseDependencies UP-TO-DATE
Task :unityLibrary:prepareLintJarForPublish UP-TO-DATE
Task :unityLibrary:bundleLibRuntimeToJarRelease UP-TO-DATE
Task :unityLibrary:mergeReleaseShaders UP-TO-DATE
Task :launcher:compileReleaseJavaWithJavac UP-TO-DATE
Task :launcher:compileReleaseSources UP-TO-DATE
Task :unityLibrary:compileReleaseShaders NO-SOURCE
Task :unityLibrary:generateReleaseAssets UP-TO-DATE
Task :unityLibrary:packageReleaseAssets
Task :unityLibrary:processReleaseJavaRes NO-SOURCE
Task :unityLibrary:bundleLibResRelease NO-SOURCE
Task :unityLibrary:mergeReleaseJniLibFolders
Task :unityLibrary:mergeReleaseNativeLibs
Task :unityLibrary:stripReleaseDebugSymbols
Task :unityLibrary:copyReleaseJniLibsProjectOnly
Task :launcher:lintVitalRelease
Task :launcher:dexBuilderRelease UP-TO-DATE
Task :launcher:mergeDexRelease UP-TO-DATE
Task :launcher:mergeReleaseAssets
Task :launcher:mergeReleaseJavaResource UP-TO-DATE
Task :launcher:sdkReleaseDependencyData UP-TO-DATE
Task :launcher:mergeReleaseJniLibFolders UP-TO-DATE
Task :launcher:validateSigningRelease UP-TO-DATE
Task :launcher:mergeReleaseNativeLibs
Task :launcher:stripReleaseDebugSymbols
Task :launcher:packageRelease FAILED
45 actionable tasks: 10 executed, 35 up-to-date
]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <4a8943a7ff7048deb64e0a5059f78d1d>:0)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <4a8943a7ff7048deb64e0a5059f78d1d>:0)
UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <4a8943a7ff7048deb64e0a5059f78d1d>:0)
UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action1[T] progress, System.String error) (at <4a8943a7ff7048deb64e0a5059f78d1d>: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 <4a8943a7ff7048deb64e0a5059f78d1d>: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 <4a8943a7ff7048deb64e0a5059f78d1d>:0)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <4a8943a7ff7048deb64e0a5059f78d1d>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <4a8943a7ff7048deb64e0a5059f78d1d>: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 <4a8943a7ff7048deb64e0a5059f78d1d>:0)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <4a8943a7ff7048deb64e0a5059f78d1d>:0)
UnityEditor.Android.PostProcessAndroidPlayer.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, AndroidPlayerBuildProgram.Data.AndroidPlayerBuildProgramOutput buildProgramOutput) (at <4a8943a7ff7048deb64e0a5059f78d1d>:0)
UnityEditor.Android.AndroidBuildPostprocessor.PostProcess (UnityEditor.Modules.BuildPostProcessArgs args, UnityEditor.BuildProperties& outProperties) (at <4a8943a7ff7048deb64e0a5059f78d1d>: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 <5f40cdb07bd44d76a23dad985a4ec283>:0)
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()

  1. Build completed with a result of ‘Failed’ in 92 seconds (92015 ms)
    UnityEditor.BuildPlayerWindow:BuildPlayerAndRun ()

  2. UnityEditor.BuildPlayerWindow+BuildMethodException: 4 errors
    at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (UnityEditor.BuildPlayerOptions options) [0x002da] in <5f40cdb07bd44d76a23dad985a4ec283>:0
    at UnityEditor.BuildPlayerWindow.CallBuildMethods (System.Boolean askForBuildLocation, UnityEditor.BuildOptions defaultBuildOptions) [0x00080] in <5f40cdb07bd44d76a23dad985a4ec283>:0
    UnityEditor.BuildPlayerWindow:BuildPlayerAndRun ()

Sounds like you have already done this step, so move onto verifying your installation.

Android build not building:

Recently (circa July 2022) there have been reports of Unity’s installer failing to install the Android Tools.

If it’s not that, then here’s how to troubleshoot:

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.

I think my editor 2021.3.8f1 is installed successfully…
And blank project sitll isn’t built as Android. But it can be built as a Window.

Well, how can I check my SDK, NDK, JDK are installed well?

I solved.
The solution was that generating new key store and setting package name correctly.

Still, I don’t know why some people don’t require setting key store and others should generate key store.

1 Like