Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Other Cant build my Unity project for android as .apk

Discussion in 'Android' started by Kernkraft, Feb 27, 2024.

  1. Kernkraft

    Kernkraft

    Joined:
    Oct 26, 2020
    Posts:
    32
    Hello Community,
    since days I have the problem to build my Unity project to an .apk file. When I try to build an empty project it works fine. But the buildsettings are the same.
    Unity Version: 2022.3.20f1 LTS
    Here are the ErrorMessages I receive:
    Error 1:
    -----------------------------------------------
    Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8

    FAILURE: Build failed with an exception.

    * Where:
    Build file 'C:\ProjectFolder\Library\Bee\Android\Prj\Mono2x\Gradle\unityLibrary\mobilenotifications.androidlib\build.gradle' line: 3

    * What went wrong:
    Could not compile build file 'C:\ProjectFolder\Library\Bee\Android\Prj\Mono2x\Gradle\unityLibrary\mobilenotifications.androidlib\build.gradle'.
    > startup failed:
    build file 'C:\ProjectFolder\Library\Bee\Android\Prj\Mono2x\Gradle\unityLibrary\mobilenotifications.androidlib\build.gradle': 3: only buildscript {} and other plugins {} script blocks are allowed before plugins {} blocks, no other statements are allowed

    See https://docs.gradle.org/7.2/userguide/plugins.html#sec:plugins_block for information on the plugins {} block

    @ line 3, column 1.
    plugins {
    ^

    1 error


    * 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 2s

    UnityEngine.GUIUtility:processEvent (int,intptr,bool&)
    -----------------------------------------------

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

    Environment Variables:
    SHIM_MCCOMPAT = 0x810000001
    PROCESSOR_ARCHITECTURE = AMD64
    AMPLITUDE_API_KEY_YELLOWBUCKET_DEV = 48835b4d1f5e342aefe5f016324d296a
    BURST_ANDROID_MIN_API_LEVEL = 22
    DriverData = C:\Windows\System32\Drivers\DriverData
    USERDOMAIN = Comp
    CommonProgramFiles(x86) = C:\Program Files (x86)\Common Files
    COMPUTERNAME = FFNB
    DEBUG_ENV_VAR = Comp
    LOGONSERVER = \\Comp
    AMPLITUDE_TOKEN_GREENBUCKET_PROD = yyzPzaIJDwrQcTNuOZsm0bhKb67WyyhK
    PUBLIC = C:\Users\Public
    ProgramData = C:\ProgramData
    SESSIONNAME = Console
    AMPLITUDE_TOKEN_YELLOWBUCKET_PROD = Ph-837Q6GNadAkyc2MRkxVcpcjlITT4d
    NVIDIAWHITELISTED = 0x01
    APPDATA = C:\Users\Comp\AppData\Roaming
    SystemRoot = C:\Windows
    windir = C:\Windows
    AMPLITUDE_API_KEY_REDBUCKET_DEV = 46b8b65825e7632fc443504b72e05fd0
    ProgramFiles(x86) = C:\Program Files (x86)
    ProgramW6432 = C:\Program Files
    OS = Windows_NT
    ANDROID_NDK_ROOT = C:\Program Files\Unity\Hub\Editor\2022.3.20f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK
    PROCESSOR_IDENTIFIER = Intel64 Family 6 Model 158 Stepping 10, GenuineIntel
    HEAP_CLIENT_TOKEN_STAGING = 3786794399
    HOMEPATH = \Users\Comp
    FPS_BROWSER_USER_PROFILE_STRING = Default
    AMPLITUDE_TOKEN_REDBUCKET_DEV = U4PSN77ppuYV9ODIvvdcgwbu9R6IHGqa
    CHROME_CRASHPAD_PIPE_NAME = \\.\pipe\crashpad_8776_ZGOXCGFGMGZKZEVB
    PROCESSOR_LEVEL = 6
    EFC_8352 = 1
    JAVA_TOOL_OPTIONS = -Dfile.encoding=UTF-8
    CommonProgramFiles = C:\Program Files\Common Files
    GOPATH = C:\Users\Comp\go
    JAVA_HOME = C:\Program Files\Unity\Hub\Editor\2022.3.20f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK
    USERDOMAIN_ROAMINGPROFILE = Comp
    TEMP = C:\Users\Comp\AppData\Local\Temp
    CommonProgramW6432 = C:\Program Files\Common Files
    AMPLITUDE_TOKEN_YELLOWBUCKET_DEV = wKi8foVigDditGrrTmZewRFWsEbX9Y0YO
    AMPLITUDE_API_KEY_GREENBUCKET_DEV = 3ded2a762169854391a425f688f760c8
    AMPLITUDE_API_KEY_REDBUCKET_PROD = ca12bb461ea9999bdf5df4ded7d52994
    HOMEDRIVE = C:
    AMPLITUDE_API_KEY_STAGING = 83ee04cv56ere4fcc7dd527c4c6f1e21
    USERNAME = Comp
    OneDrive = C:\Users\Comp\OneDrive
    AMPLITUDE_API_KEY_YELLOWBUCKET_PROD = e03a9bbezuzc38a88cdb878d24c65b46
    PATHEXT = .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
    AMPLITUDE_TOKEN_REDBUCKET_PROD = QqyoFpcWui45E17p80_46CF6-sNGRGbHo
    NUMBER_OF_PROCESSORS = 12
    AMPLITUDE_TOKEN_GREENBUCKET_DEV = 84H2gMm_FJzhr3mBaX09OIjVukmCM7d9
    AMPLITUDE_DEPLOYMENT_KEY_RED_BUCKET_DEV = client-wbjHYrmeSR87GmwO89tzrpf7sUySOIKHm
    PSModulePath = C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
    AMPLITUDE_API_KEY_GREENBUCKET_PROD = c86fea37a9e1d3443fftsb96e15b111c7c
    ComSpec = C:\Windows\system32\cmd.exe
    ORIGINAL_XDG_CURRENT_DESKTOP = undefined
    PROCESSOR_REVISION = 9e0a
    AMPLITUDE_DEPLOYMENT_KEY_RED_BUCKET_PROD = client-zH8Y7OK1i331OPzT4327C6UxN8ygcM6LzS
    TMP = C:\Users\Comp\AppData\Local\Temp
    SystemDrive = C:
    AMPLITUDE_API_KEY = 28f3cae0b33b8b3702120c9ed1a935aa
    FPS_BROWSER_APP_PROFILE_STRING = Internet Explorer
    OneDriveConsumer = C:\Users\Comp\OneDrive
    SENTRY_ACCESS_TOKEN = 3df78d9e53f845dda78fbaezuzce1a6261421ab1d0999974bc2e933477289017
    HEAP_CLIENT_TOKEN = 1717354662
    ALLUSERSPROFILE = C:\ProgramData
    Path = C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\dotnet\;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program Files\Docker\Docker\resources\bin;C:\Program Files\Git\cmd;C:\Program Files\PuTTY\;C:\Program Files\WireGuard\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Go\bin;C:\Users\Comp\AppData\Local\Microsoft\WindowsApps;;C:\Users\Comp\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Comp\.dotnet\tools;C:\Users\mcfis\go\bin
    ProgramFiles = C:\Program Files
    LOCALAPPDATA = C:\Users\Comp\AppData\Local
    USERPROFILE = C:\Users\Comp
    WOOTRIC_CLIENT_TOKEN = NPS-aa8gd4c3


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

    FAILURE: Build failed with an exception.

    * Where:
    Build file 'C:\ProjectFolder\Library\Bee\Android\Prj\Mono2x\Gradle\unityLibrary\mobilenotifications.androidlib\build.gradle' line: 3

    * What went wrong:
    Could not compile build file 'C:\ProjectFolder\Library\Bee\Android\Prj\Mono2x\Gradle\unityLibrary\mobilenotifications.androidlib\build.gradle'.
    > startup failed:
    build file 'C:\ProjectFolder\Library\Bee\Android\Prj\Mono2x\Gradle\unityLibrary\mobilenotifications.androidlib\build.gradle': 3: only buildscript {} and other plugins {} script blocks are allowed before plugins {} blocks, no other statements are allowed

    See https://docs.gradle.org/7.2/userguide/plugins.html#sec:plugins_block for information on the plugins {} block

    @ line 3, column 1.
    plugins {
    ^

    1 error


    * 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 2s
    ]
    stdout[

    ]
    exit code: 1
    UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <350bddde343340be9c3b2ea115fe87e9>:0)
    UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <350bddde343340be9c3b2ea115fe87e9>:0)
    UnityEditor.Android.Command.Run (System.String command, System.String args, System.String workingdir, UnityEditor.Android.Command+WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg) (at <350bddde343340be9c3b2ea115fe87e9>:0)
    UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1[T] progress, System.String error) (at <350bddde343340be9c3b2ea115fe87e9>: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 <350bddde343340be9c3b2ea115fe87e9>: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 <350bddde343340be9c3b2ea115fe87e9>:0)
    UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <350bddde343340be9c3b2ea115fe87e9>:0)
    UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context) (at <350bddde343340be9c3b2ea115fe87e9>:0)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr, Boolean&)
    -----------------------------------------------

    I have already deleted the gradel folder and compared the gradle.build files of both look the same.

    While building it always crashes at this step:
    Calling IPostGenerateGradleAndroidProjects callbacks

    I hope someone can help me with this.
    Thanks in advance.
     
    Last edited: Feb 27, 2024