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.

settings.gradle files.File > Invalidate Caches... (all of them) and restarted AS, but this didn't help.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?
Problem solved.
For the benefit of all, I am posting here a summary of what I did to solve it:
C:\Users\<yourname>\AppData\Local\Google\AndroidStudio2022.1\log\idea.log is key to finding clues to the mystery.mklink /D "jre" "jbr" which miraculously revived the build process (see https://github.com/flutter/flutter/issues/106674#issuecomment-1381685888).File > Settings > Build Tools > Gradle, this is the Java version that works for me:
I then tried to follow Sync's output to use Gradle 7.5.0. It could not be found on any of the repositories in my top level build.gradle and resulted in chasing my tail... According to https://developer.android.com/reference/tools/gradle-api Gradle's current release is 7.4.0, so I reverted to using it (why didn't it work the first time, I don't know) and here is my working top level build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        gradlePluginPortal()  
        mavenCentral()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.4.0'
        classpath("de.mannodermaus.gradle.plugins:android-junit5:1.8.2.1")
        classpath("org.mockito:mockito-inline:4.11.0")
    }
}
allprojects {
    repositories {
        gradlePluginPortal()
        mavenCentral()
        google()
    }
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With