Awful android build experience

Unity 2020.3.11f1.

At some point android build started printing “Gradle failed to fetch dependencies” every time I open a specific project.

Error details speak about missing JAVA_HOME variable.

In order to make the error go away, it is necessary to go editor preferences, then “External Tools → Android → JDK Installed” and then toggle the checkbox here. If it is set, then you should unset it, and if it is unset, then you should set it. That will make the error go away.

Because unity allows simultaneous installation of multiple versions, I shouldn’t ever need to set JAVA_HOME, since different editor versions might be using different JDK.

The checkbox trick worked for a while, but now the editor fails to build at all. It simply waits for 30 minutes while building the very first scene.

7483820--920594--upload_2021-9-9_18-3-29.png

Judging by process explorer, it just starts a dozen instances of shader compiler and then sits there doing nothing.

So, how the heck do I fix this thing?

Apparently in case of situation like this, going into Assets → External Dependency Manager → Android Resolver → Settings and unchecking “Resolve on Build” fixes the issue. Fixes the initial freeze while building the first scene, at least.

The editor is still going to pester about JAVA_HOME and Gradle failing to fetch dependencies, though.

This maneuver cost us couple of hours. Resolved. By a miracle or through a blessing of Azatoth of something like that.

I’ll describe this situation in case somebody else runs into it.

  1. Pulling updates from upstream branch, opening the project in unity.
  2. Gradle doesn’t work “Coudl not resolve packages”. Investigation shows that it complains about “JAVA_HOME” not being set. That one’s misleading, because setting JAVA_HOME does not do sqquat, so even if you do set it, nothing’s gonna hange.
  3. I try to force update packages through Android Resolver. No effect! Force Update, Update, nothing.
  4. I go to the external options and toggle on/off the openjdk path. That makes Gradle to shut up.
  5. I attempt to build and it hangs on the first scene. I tried to wait for it, but after 30 minutes I figure it is actually stuck.
  6. This thread indicates that the idea is to actually uncheck “resolve packages before build”. Unity 2019.2 build stuck on scene 0 - Questions & Answers - Unity Discussions , by unchecking "Enable Resolution to Build’. This has some effect, and build process starts moving forward, but…
  7. But NOPE. Build errors at the last stage. The exact wording is along the lines of “InvokeCommand fails” or “processEvent fails” the thing is, clicking on error message to see it in console breaks editor and it starts throwing errors.
  8. I pull up Editor.log (%LOCALAPPDATA%/Unity/Editor/Editor.log). And NOW I can see something interesting. error: package com.google.android.gms.maps does not exist import com.google.android.gms.maps.GoogleMap. So it can’t find google map libraries, and then everything fails, because the project is relying on those.
  9. I tinker with various settings a bit more trying to find a combination where things work, nope, no resultr.
  10. I check out first ever version where google map dependency was introduced, try to build it… that one works.
  11. I attempt to go back to the lastest version (which was broken). Notice it complaining about missing %userprofile%/.android/repositories.cfg , so I make it an empty file so it shuts up.
  12. I attempt another build, and (Sweet mother of Cthulhu), it works.

So it got resolved. Somehow. And something apparently wrecked buil;d process at some point. Somehow. And it got fixed. Somehow.

If anyone has additional information, I’m all ears. If not, perhaps it will be useful for someone else.

My builds are successful but problem is doing all this make google play plugin unstable and so it never shows adds .is this problem with unity version ??? It has to be streamline then such mess