Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build a Simple Android App (2014) Creating the Screen Layout Getting to Know Our Tools

Tommy Binkley
Tommy Binkley
18,584 Points

Trouble Running Android Studio

I can open up android studio but i keep getting an error saying in the messages Error: (3, 22) and it says Download JDK 7, Select A JDK From The File System, Open build.gradle File. So I did download JDK 7 I download all the JDK 7 files on the website and I restarted my computer and it still has the same error. I dont know how to select it because I cant find the right file. I would like for Android Studio to work so i cant get past the first couple of steps to making my android app.

5 Answers

Lauren Kimlinger
Lauren Kimlinger
2,470 Points

What OS are you running? Windows, Mac, Linux?

Here's a link to a stackoverflow answer that might help: http://stackoverflow.com/questions/24472020/android-studio-needs-jdk-7-for-android-l-mac

Tommy Binkley
Tommy Binkley
18,584 Points

Mac. I have downloaded multiple files for JDK 8 and then I go into my Terminal and type Java -version and now it says I Have 8.0 Installed but I need help setting it as my JAVE_HOME

I watched this video on youtube and it says type in:

open -a TextEdit ~/.bash_profile

And my terminal says:

The file /Users/admin/.bash_profile does not exist.

Lauren Kimlinger
Lauren Kimlinger
2,470 Points

Try typing this into the terminal:

echo export "JAVA_HOME=\$(/usr/libexec/java_home)" >> ~/.bash_profile

and then restart the terminal.

Here's a link to the stackoverflow answer where I found this: http://stackoverflow.com/questions/22842743/setting-java-home-environment-variable-on-mac-osx-10-9

Tommy Binkley
Tommy Binkley
18,584 Points

I typed exactly what you had and it said "No such file or directory" but when I type in "java -version" it says " java version "1.8.0_40" Java(TM) SE Runtime Environment (build 1.8.0_40-b27) Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)"

Please help before my free trial expires.

Lauren Kimlinger
Lauren Kimlinger
2,470 Points

If I understand you, when you open up Android Studio, you get a dialog box asking you where the JDK is.

It seems that the answer is different if you downloaded it from Oracle (the numbers might be different, but look for the .jdk):

/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home

or Apple:

/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/

Here's the original link: http://stackoverflow.com/questions/6141180/mac-os-x-10-6-7-java-path-current-jdk-confusing

Tommy Binkley
Tommy Binkley
18,584 Points

OK so i do get a dialog box in android studio saying i need to download JDK 7 so then i finally read where you said it would be under apple. and now what do i do because it is still saying it do i restart my computer and android studio or is there more to do?

Lauren Kimlinger
Lauren Kimlinger
2,470 Points

So you browsed using the dialog box and found where Java was installed, then clicked the "OK" or "Enter" button, but it is still saying you need to download it? Did you verify that Java is installed there by looking in the folder? Sometimes when you uninstall Java, the folder is still there even though the program is gone. You might need to look elsewhere.

As you can tell, I'm running out of ideas. It sounds like you're doing everything right, so it's hard to tell what the problem is.

Tommy Binkley
Tommy Binkley
18,584 Points

Correct. I did open Terminal and typed Java -version and it says it is installed with JAVA 8 and I did restart my computer and in android studio in the bottom on the screen in the messages gradle sync it says download JDK 7, Select a JDK from a file form, open Build.gradle file. so is there a code i can type in terminal to find where the home for java is so i can locate it in android studio?

Tommy Binkley
Tommy Binkley
18,584 Points

everytime i try to run something in android studio it says gradle project sync failed ( error 3, 22) every

Tommy Binkley
Tommy Binkley
18,584 Points

maybe JDK 7 only works with android studio idk. Maybe you can send me a link to JDK 7 download because i cant find it anywhere.

Tommy Binkley
Tommy Binkley
18,584 Points

I got it working now. The only thing i did was downgrade my android studio to the previous software and everything is up and runnning now.

Lauren Kimlinger
Lauren Kimlinger
2,470 Points

I'm so glad you figured it out! Happy coding!