9

I'm creating an Android project with Gradle Android Module, but as soon as I create it, I have an error I don't understand and I have no idea to resolve it. It says

Gradle project sync failed. Basic functionality (e.g editing, debugging) will not work properly" or "Gradle 'myapp' project refresh failed: A fatal exception has occurred. Program will exit. : Gradle settings

If you have an idea of what causes this problem or if you have already encountered it, please tell me what to do.

rajah9
  • 11,645
  • 5
  • 44
  • 57
user3441190
  • 111
  • 1
  • 1
  • 3

5 Answers5

6

Came across this issue when I was having similar issue. I solved this problem as follows

  1. Download and extract gradle file to directory of choice

  2. Set the environmental variable for gradle, I think this has no effect in the solution.

  3. Go to intellij and access setting window through File -> Setting

  4. On setting window, go to Build, Execute. Deployment -> Build Tools -> Gradle

  5. Check "Use local gradle distribution"

  6. From Gradle home field access gradle installed path

Please note, I am working with intellij 15.

olatno
  • 189
  • 2
  • 5
1

I have run into the same problem. Part of it may be that you have recently installed the Android SDK and have not accepted the license agreement. Here are the steps you can take. (I was using IntelliJ Ultimate IDEA 14.0.2.)

  1. Stop IntelliJ and restart it with Admin privileges. (You will be expanding zip files in the Program Files (x86) directory, and won't be able to do so unless you are an administrator).
  2. On the "messages Gradle Sync" (bottom window), there is a hyperlink that says Error: "Install Repository and sync project." Click on it.
  3. Accept the License Agreement.
rajah9
  • 11,645
  • 5
  • 44
  • 57
0

Post the logs from Event Log window. One possibility could be that the gradle setting file is pointing to a non-existing version of gradle. You can find it under gradle -> wrapper -> gradle-wrapper-properties

gandharva
  • 691
  • 5
  • 16
0

Problem: If you are getting error as 'gradle sync issue". We have to build very first time from command prompt (not from intellij)

Solution: Step 1:

  • Setup user environment variable for jdk 11: Variable: JAVA_HOME Value: C:\Program Files\Java\jdk-11.0.14

Step 2:

  • Go to your project path (File explorer)
  • Open cmd prompt
  • type "gradlew clean build"
  • build should start
  • no worries, either build success or failed

Step 3: Open intellij project and open intellij terminal and again run the same command

"gradlew clean build"

Step 4:

  • Go to build tab (bottom of the intellij window)
  • Go to sync tab -> Make sure it should show as "BUILD SUCCESSFUL"

Step 5: now again go to intellij terminal and again run the same command

"gradlew clean build"

Now you will be able to see your test execution results. Please verify report

Please let me know if there is any question.

0

I have a similar error like yours. If I changed gradle JDK to 13 then it works fine, but I can only use Jdk8 in our project. Everytime when the gradle/jdk changed to 8, it shows Sync failed. Then I tried to use another JDK(Amazon Corretto 1.8), then Gradle works. I don't know the reason, but hope it is useful for you.

Songtao Lou
  • 41
  • 11