0
\$\begingroup\$

I'm using Unity 2020 to build for Android. Unity provides a mainTemplate.gradle file, looks a bit like this.

As per Unity docs, there are certain template variables that Unity will fill in when it generates the actual build.gradle file.

What the docs don't mention at all is what the logic is behind how these are filled in. The specific issue I have is that it defaults to a version of the build tools that's too old for a particular entry in my manifest. As such, I'm trying to override BUILDTOOLS, but I've not been able to find anything online about either manually overriding an arbitrary template variable, or explicitly setting the Build Tools version.

All the docs say is SDK Build tools used (for example, 25.0.1)., completely unhelpfully.

Any advice welcome.

\$\endgroup\$
3
  • \$\begingroup\$ What version of the Android SDK do you have installed? Does the SDK have a build tools version setting? \$\endgroup\$
    – DMGregory
    Jun 11, 2021 at 11:52
  • \$\begingroup\$ I had two versions of build tools, 28.0.3 which I didn't want, and 30.something. In the end it just needed a Unity restart to pick up the newer version. So I assume it just ends up choosing whatever's newer in the SDK that's bundled with it. \$\endgroup\$
    – Vlad
    Jun 12, 2021 at 13:18
  • \$\begingroup\$ Want to write up your solution as an Answer below? \$\endgroup\$
    – DMGregory
    Jun 12, 2021 at 13:20

1 Answer 1

1
\$\begingroup\$

After mucking around with Unity a bit more, I think what happens is that it picks the highest version of the Build Tools component that is installed.

What I didn't realize is that I needed to restart Unity for that to happen. I also deleted Temp/gradleOut for good measure. So, between these two actions, it eventually started working.

I still haven't got a clue whether it's possible to give those template variables custom values.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .