I found several SO posts describing similar issues, but they are outdated and none were found to be helpful in regard to my upgrade to the latest version of Android Studio.
After upgrading my Android Studio from version 2021.3.1
to version 2022.1.1
, my attempt to File > Sync Project with Gradle Files
results in Sync failed (within less than 200ms).
When I try to Build > Rebuild Project
, I get the following error:
Unable to find Gradle tasks to build: [:].
Build mode: REBUILD.
Tests: None.
- There is no :app in any of my
settings.gradle
files. - I did
File > Invalidate Caches...
(all of them) and restarted AS, but this didn't help. - I also deleted all
build
folders, but this didn't help.
Any idea how to solve this?
Right-clicking the Sync failed to Reload Gradle Project
results in the same failure but it opens now a bar on top of the editor window with the Show Log in Explorer
link. When I click it, I indeed find idea.log
in C:\Users\WebViewer\AppData\Local\Google\AndroidStudio2022.1\log
. I am inspecting it now...
Update:
The first thing I noticed in idea.log is the following exception:
org.gradle.tooling.GradleConnectionException: Could not run phased build action using connection to Gradle distribution 'https://services.gradle.org/distributions/gradle-7.4-bin.zip'.
...
Caused by: org.gradle.internal.jvm.JavaHomeException: The supplied javaHome seems to be invalid. I cannot find the java executable. Tried location: C:\Program Files\Android\Android Studio\jre\bin\java.exe
Thanks to this SO tip, I did mklink /D "jre" "jbr"
which all of a sudden revived Android Studio and started to download lots of Gradle related packages.
I still have "Gradle Sync issues" but at least Android Studio prompts me now how to solve them:
but... according to https://developer.android.com/reference/tools/gradle-api Gradle's current release is 7.4.0
, why is Android Studio asking for a minimum of 7.5
?