Reputation: 1553
I am getting following error while trying to run my app from android studio
Execution failed for task ':app:compileDebugJava'. Cannot find System Java Compiler. Ensure that you have installed a JDK (not just a JRE) and configured your JAVA_HOME system variable to point to the according directory
.
After searching on internet, I found some solution like this
export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_45/
so i gave this command in terminal from android studio dirctory but its not workout it show the same error again.
Upvotes: 23
Views: 64692
Reputation: 61
To fix this error in Andriod Studio 2.3.1 I had to go to File > Project Structure or Ctrl+Alt+Shift+S then go to SDK Location which was already open for me and then uncheck "Use embedded JDK" and point to where my installed version was.
*
The mentioned post really solved my problem after long searching.
*
Upvotes: 2
Reputation: 86
To fix this error in Andriod Studio 2.3.1 I had to go to File > Project Structure
or Ctrl+Alt+Shift+S then go to SDK Location which was already open for me and then uncheck "Use embedded JDK" and point to where my installed version was.
Upvotes: 5
Reputation: 1582
Updating my Gradle build version did the trick for me.
Old:
classpath 'com.android.tools.build:gradle:1.0.0'
New:
classpath 'com.android.tools.build:gradle:2.2.3'
Edit: Since this answer is still being used frequently, note that Gradle 2.2.3 can probably be substituted with any newer version of Gradle. This version just happened to be the version I was using when I originally answered the question.
Upvotes: 69
Reputation: 151
I have this problem a lot when I try to open older projects for the first time. It seems that I just need to update the classpath under build.gradle:
In my case the old version was:
classpath 'com.android.tools.build:gradle:1.3.0'
and I updated to:
classpath 'com.android.tools.build:gradle:2.3.2'
Sync the gradle and it should compile.
Upvotes: 0
Reputation: 293
In your android-studio find it in File->Other Settings->Default Project Structure->SDKs.
Then Check with JDK LOCATION select Installed JDK Location and APPLY IT.
Upvotes: 1
Reputation: 1553
In your android-studio find it in File->Other Settings->Default Project Structure->SDKs. Then i changed JDK home path.
Upvotes: 51
Reputation: 4520
In the android studio
Window -> preferences -> Java -> Installed JREs and select your JDK home path
or else please follow the link to set JAVA_HOME in linux machines
Upvotes: 1