Search Unity

How to build for Target SDK 30?

Discussion in 'Android' started by Itzhak_P, Nov 7, 2021.

  1. Itzhak_P

    Itzhak_P

    Joined:
    Apr 28, 2015
    Posts:
    12
    So I got an error from Playstore that I need to set Target SDK to at least 30.
    I installed the SDK in android studio, set the path in the Unity preferences. But when I build it fails with error:
    Code (CSharp):
    1. Could not determine the dependencies of task ':launcher:bundleReleaseResources'.
    2. > Installed Build Tools revision 31.0.0 is corrupted. Remove and install again using the SDK Manager.
    From what I read build tool 31 is not supported with the default gradle version of Unity 2020.
    I see in the gradle a line
    Code (CSharp):
    1. buildToolsVersion '**BUILDTOOLS**'
    But not sure where BUILDTOOLS is set.
    I tried to change the line manually to
    Code (CSharp):
    1. buildToolsVersion '30.0.3'
    In the mainTemplate.gradle
    But I still get the same error!
    why would it still use tools version 31?
    What is the supported way to build to Playstore using Unity 2020?
     
  2. Voxel-Busters

    Voxel-Busters

    Joined:
    Feb 25, 2015
    Posts:
    1,963
    If you want to delete API 31,
    Go to Unity's Android SDK Installation path and delete following folders
    1. platforms/android-31 folder
    2. build-tools/31.x.x folder
     
  3. Itzhak_P

    Itzhak_P

    Joined:
    Apr 28, 2015
    Posts:
    12
    Thanks! deleting this worked (I did try to delete it before but somehow it got re-installed)
    I still wonder why it used build tools 31 when the gradle states 30.0.3

    Also I would still like to find how to change BUILDTOOLS from unity settings instead of having to manually change the gradle file.
     
  4. Voxel-Busters

    Voxel-Busters

    Joined:
    Feb 25, 2015
    Posts:
    1,963
    Unity replaces the BUILDTOOLS value runtime when exporting. I don't know a way to force it other than changing the Automatic option for Target Api.

    How did you find out that its still using 31 tools?