15

In hindsight I should not have enabled L build stuff.

I am new to programming and I created a new Android Studio project which is throwing the Gradle errror right away.

Errors are:

yellow bar at the top - Gradle project sync failed. Basic functionality (e.g. editing, debugging) will not work properly. Try again Open Event Log Show Log in Finder

messages gradle sync - compileSdkVersion android-L requires compiling with JDK-7. open sdk settings, open file.

tried looking through google and other stack overflow comments but did not find much I could make sense of except for Android Studio - Gradle sync project failed

tried converting URL to 1.10 instead of 1.12 and syncing but that failed after syncing

I need help either getting L working or removing it so that a new studio project can compile to device without errors.

Community
  • 1
  • 1
NukeouT
  • 409
  • 1
  • 9
  • 20
  • figured it out: Downloaded JDK 8.11 then used terminal to ask the system where it was installed. Pasted install path into the UI window that comes up from the error hotlink and it began to sync immediately. http://stackoverflow.com/questions/15826202/where-is-java-7-installed-on-mac-os-x – NukeouT Jul 20 '14 at 21:00

10 Answers10

8

I too faced the same issue and after days of trouble I figured it out. Just check if Java is installed

  • Open a Terminal window and type:

java -version

Any version above JDK 6 is OK

  • In terminal type

open -a TextEdit ~/.bash_profile

  • Copy and paste the following lines of into textedit

export JAVA_HOME=$(/usr/libexec/java_home)

export JDK_HOME=$(/usr/libexec/java_home)

  • Save it, close editor and type the following to apply changes

source ~/.bash_profile

Now try gradle sync now, you must be able to complete sync

reku
  • 753
  • 9
  • 17
6

The most simple solution (at least for me) would be:

Go to SDK manager (with Administrator rights), scroll down till the end, download "Android Support Library".

And it works (don't forget Administrator rights).

igor
  • 69
  • 1
  • 5
3
  1. Uncheck "Offline work" in File>Settings>Gradle>Global Gradle Settings
  2. Resync the project, for example by restarting the Android Studio.
  3. Once synced, you can check the option again to work offline
  4. Update java if Android L SDK installed
  • 2
    on my Android Studio, it's File -> Other Settings -> Default Settings -> click -> select Gradle. However, "Offline Work" was already unchecked – Someone Somewhere Dec 17 '14 at 23:44
2

For me Changing the JDK path worked. I changed it to /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home

in File--> ProjecStructure-> JDK location.

Mac
  • 21
  • 1
  • This fixed it for me. Android Studio 1.1.0 OSX – rygo6 Mar 08 '15 at 07:15
  • That was it for me as well. The message from Gradle is a bit misleading as one can think gradle is reading it as environmental variable, and it turns out tt's from Android Studio settings. – Juan Mendez Jun 15 '15 at 13:58
2
  1. Open Gradle Settings in File > Settings > Gradle
  2. Select the Option 'Use local gradle distribution'
  3. Enter the URL of your local gradle version here.
2

When installing Android Studio on Mac OSX Sierra, I received an error that my JVM is not valid. So I came here to a different post and installed Apple's legacy version and the up-to-date version. It worked. Then when I was creating a project I ran into another error which was the Gradle sync issue. Came here (this very post by "Mac") again and changed the JDK version that Android Studio was pointing to (obviously I chose to "detect" instead of browsing for the up-to-date version). Everything is working fine now.

Community
  • 1
  • 1
kingcong
  • 21
  • 2
1

A complement to igor's anwswer: for me "Android Support Library" wasn't enough. You would probably like to add "Android Support Repository" also.

As he said:

don't forget Administrator rights ;)

Community
  • 1
  • 1
Adrian
  • 324
  • 2
  • 10
1

Mine was looking for the Java SDK in "Macintosh_HD>System>Library>Java> etc." but my most recent update was in "Macintosh_HD>Library>Java etc."

I set this after clicking in the error window saying 'open SDK' 'open file' which brings you to the screen where to set the path for Java.

Joel
  • 197
  • 1
  • 10
1

this happen with me when I try import wrong repository complie 'me.dm7.barcodescanner:zxing:1.7.2' , so any one face this problem may be that be the reason

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.1.1'

} 
Mina Fawzy
  • 20,852
  • 17
  • 133
  • 156
1

The most simple solution (at least for me) would be:

Go to SDK manager (with Administrator rights), scroll down till the end, download "Android Support Library".

And it works (don't forget Administrator rights).

I am using windows 7 works properly thanks igor