Search Unity

Question Building for Android with Unity 2021.2.18f

Discussion in 'Android' started by camouflaged_penguin, Jul 5, 2022.

  1. camouflaged_penguin

    camouflaged_penguin

    Joined:
    Jun 1, 2021
    Posts:
    22
    Hey there i am trying for hours to make an Android Build with Unity 2021.2.18f. No matter what i tried, it doesn't work.

    The first thing i get is a prompt to update the Android build tool currently installed. When i click yes, i get some error messages i will add to this Question. Some folders could not be accessed or created. If i click "Highest Version" i get different error messages.

    WARNING: The option setting 'android.enableR8=false' is deprecated.
    It will be removed in version 5.0 of the Android Gradle plugin.

    WARNING: The specified Android SDK Build Tools version (28.0.3) is ignored, as it is below the minimum supported version (29.0.2) for Android Gradle Plugin 4.0.1.
    Android SDK Build Tools 29.0.2 will be used.
    To suppress this warning, remove "buildToolsVersion '28.0.3'" from your build.gradle file, as each version of the Android Gradle Plugin now has a default version of the build tools.
    WARNING: The specified Android SDK Build Tools version (28.0.3) is ignored, as it is below the minimum supported version (29.0.2) for Android Gradle Plugin 4.0.1.
    Android SDK Build Tools 29.0.2 will be used.

    Exception while marshalling

    FAILURE: Build failed with an exception.

    * What went wrong:
    Could not determine the dependencies of task ':launcher:compileReleaseJavaWithJavac'.
    > Failed to install the following Android SDK packages as some licences have not been accepted.
    build-tools;29.0.2 Android SDK Build-Tools 29.0.2
    To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
    Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html

    ___________________________

    How can i even accept SDK licenses for the in unity installed Android Studio Version?
    I tried to find some info about these Problems but all i have found did not work so far.
    Does someone know whats going on? f1.png f2.png
     
  2. Voxel-Busters

    Voxel-Busters

    Joined:
    Feb 25, 2015
    Posts:
    1,963
    Give a try with the following
    1. Set Target API to 31 in Player Settings -> Android
    2. Make a build
    3. It may prompt for Updating the sdk, proceed with it
    4. Later you can set Target api back to Automatic

    If the above process doesn't work (which is possible in a diff scenario where it may need admin access for writing sdk folders), let me know. I have another workaround.
     
  3. camouflaged_penguin

    camouflaged_penguin

    Joined:
    Jun 1, 2021
    Posts:
    22
    no
    same problems as before.
     
  4. Voxel-Busters

    Voxel-Busters

    Joined:
    Feb 25, 2015
    Posts:
    1,963
    Ok, whats the error now? Share me the entry under CommandInvocationFailure(once you click that entry).
     
  5. camouflaged_penguin

    camouflaged_penguin

    Joined:
    Jun 1, 2021
    Posts:
    22
    ok this is the message i get, when the game prompts me to upgrade:
    BTW i am pretty sure this error could be related to Windows 11 and its Access Management.
    Because collegues with the same setting, running Windows 10 don't have these problems.

    Maybe i downgrade but i would like to know if there is a workaround.



    UnauthorizedAccessException: Access to the path 'C:\??\Unity\Hub\Editor\2021.2.18f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\tempToolsDir' is denied.
    System.IO.FileSystem.CreateDirectory (System.String fullPath) (at <6073cf49ed704e958b8a66d540dea948>:0)
    System.IO.Directory.CreateDirectory (System.String path) (at <6073cf49ed704e958b8a66d540dea948>:0)
    UnityEditor.FileUtil.CopyDirectoryFiltered (System.String source, System.String target, System.Boolean overwrite, System.Func`2[T,TResult] includeCallback, System.Boolean recursive) (at <1f61d5eefcc74dff84f661b4a4dc8479>:0)
    UnityEditor.FileUtil.CopyDirectoryFiltered (System.String source, System.String target, System.Boolean overwrite, System.String regExExcludeFilter, System.Boolean recursive) (at <1f61d5eefcc74dff84f661b4a4dc8479>:0)
    UnityEditor.FileUtil.CopyDirectoryRecursiveFiltered (System.String source, System.String target, System.Boolean overwrite, System.String regExExcludeFilter) (at <1f61d5eefcc74dff84f661b4a4dc8479>:0)


    when i click "use highest installed" i get this:
    Starting a Gradle Daemon, 1 incompatible Daemon 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

    FAILURE: Build failed with an exception.

    * What went wrong:
    Could not determine the dependencies of task ':launcher:compileReleaseJavaWithJavac'.
    > Failed to install the following SDK components:
    build-tools;29.0.2 Android SDK Build-Tools 29.0.2
    The SDK directory is not ...

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

    stderr[
    FAILURE: Build failed with an exception.

    * What went wrong:
    Could not determine the dependencies of task ':launcher:compileReleaseJavaWithJavac'.
    > Failed to install the following SDK components:
    build-tools;29.0.2 Android SDK Build-Tools 29.0.2
    The SDK directory is not writable (C:\???\Unity\Hub\Editor\2021.2.18f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK)
     
  6. Voxel-Busters

    Voxel-Busters

    Joined:
    Feb 25, 2015
    Posts:
    1,963
    Can you try the next workaround?
    #2 Try running unity (hub) as admin and build again
     
    Last edited: Jul 6, 2022
  7. camouflaged_penguin

    camouflaged_penguin

    Joined:
    Jun 1, 2021
    Posts:
    22
    yes tried it already. didn't work. Same problem.
     
  8. Voxel-Busters

    Voxel-Busters

    Joined:
    Feb 25, 2015
    Posts:
    1,963
    Ok, Option #3 (This should work as a last resort)
    1. Open Android SDK install folder (Android studio's)
    2. Copy build-tools/30.0.2 to Unity's android sdk's build tools folder
    3. Copy platforms/android-31 from Android sdk to unity's android sdk platforms folder.

    Basically, you are copying manually from Android sdk install with Android studio to unity's android sdk.