A project created in Android Studio can be fully built by executing the following command at the top of the directory.
gradlew.bat assemble
However, depending on the environment, the following error may be displayed.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> Kotlin could not find the required JDK tools in the Java installation 'C:\Program Files\Java\jre1.8.0_181' used by Gra
dle. Make sure Gradle is running on a JDK, not JRE.
...(Omission)...
BUILD FAILED in 3s
13 actionable tasks: 13 executed
This is because, as shown in the error message, the ** JDK ** required for the build is not in the path, but the ** JRE ** is in the path.
--JDK = Java Development Kit: Library for developing applications in Java --JRE = Java Runtime Environment: Library for running Java applications
Search for "path" from the Start menu to launch "Edit System Variables" and click "Environment Variables"
Click "New" in "System Variables" at the bottom of the screen
Set the path of the JDK installed with the variable name JAVA_HOME
to the variable value and click OK
Reboot the command line and hit the same command again to see if you can build
Recommended Posts