In your android-studio find it in File->Other Settings->Default Project Structure->SDKs. Then i changed JDK home path.
Android studio error After run the project
-
14-10-2022 - |
Question
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.
Solution 2
OTHER TIPS
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.
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.
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.
*
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
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.
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.