Reputation: 319
I downloaded a Android project and wanted to try it. So I imported it to Android Studio (2.2) and when running the project i get the error:
Error: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.
Before the runnning of every project worked and i'm searching for days but still found no working solution.
EDIT: Here is my project structure: project structure
Maybe someone of you has the solution.
Upvotes: 16
Views: 38990
Reputation: 1
editing inside build.gradle(Project: App name)
dependencies {
implementation 'com.android.tools.build:gradle:3.6.2'
//update latese gradle build version.
}
then sync it.
Upvotes: 0
Reputation: 1191
This kind of problem arises when you compile old project in your new updated Android Studio IDE Version. Technically speaking : gradle build version is old. Just update with new
This can be achieve editing inside build.gradle(Project: App name)
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
//update latese gradle build version.
}
This might do the trick.
Upvotes: 14
Reputation: 1774
I had the same issue. It turned out to be old versions of the buildscript dependencies classpath, and the buildToolsversion, that were included in the project config files. This was not related to the JDK path, changing the JDK path didn't help.
I followed this answer, with these additions:
In step 1, the gradle-wrapper.properties
file is inside the gradle/wrapper
folder in my main project folder. The lowest gradle version that Android Studio accepted here was gradle-3.3-all.zip
In step 4, for the classpath gradle version I used 2.3.2, this is the latest non-alpha version that I found, that works here. (not sure why these versions are different. but it works)
I also had to change the buildToolsVersion to '25.0.0' from the old '20.0.0', inside the file build.gradle
in my module sub-folder.
Now I can compile the project in Android Studio successfully.
(The file gradlew
in the project main folder is generated once at the project creation, and can be regenerated. It can be used to run gradle commands manually, such as debugging this issue. But it was not needed for this solution.)
Upvotes: 5
Reputation: 470
I think, you didn't setup JDK for current project. You've just loaded the code. Do it in project structure.
You can do it here: File > Project Structure > [Platform Settings] > SDKs.
Upvotes: 10