Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle sync failed with reason unknown - Android studio 4.2.1 [closed]

Tags:

android

gradle

Gradle sync failed: Sync failed: reason unknown

Tried solutions

  1. Invalidate cache and restart
  2. reinstalled android studio and recloned project
  3. changed the gradle version
  4. removed .gradle and .idea folder
  5. run gradle build from cli
  6. toggling offline mode
  7. Manually pointed gradle files

using Android studio 4.2.1 and gradle 6.5

like image 612
Karthik M Avatar asked Jun 29 '21 06:06

Karthik M


People also ask

How do I sync gradle with Android Studio?

Open your gradle. properties file in Android Studio. Restart Android Studio for your changes to take effect. Click Sync Project with Gradle Files to sync your project.


2 Answers

In your screenshot, there is a infomation bar on top of the editor area "Gradle project sync failed. Basic funtionality will not work." Click the "Show log in finder", you can check the real reason in the log file.

In my case, I found “ Module: 'xxxxx' platform 'android-26' not found” which mean the platform 26 is missing. After download the platform api level 26, problem solved.

like image 66
situee Avatar answered Sep 28 '22 11:09

situee


There is great post here: https://www.tehrir.com/gradle-sync-failed in this matter.

Make sure your Android Gradle Plugin version matches Gradle version according to this page: https://developer.android.com/studio/releases/gradle-plugin#updating-gradle

enter image description here

If it matches and still gives same error try upgrading to a higher "tier":

4.2.1 and 6.7.1

It worked for me.

like image 35
Variag Avatar answered Sep 28 '22 12:09

Variag