[JAVA] What to do if build from command line fails in Android development environment

Premise

Events and causes

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

solution

Search for "path" from the Start menu to launch "Edit System Variables" and click "Environment Variables" システムプロパティ.png

Click "New" in "System Variables" at the bottom of the screen 環境変数.png

Set the path of the JDK installed with the variable name JAVA_HOME to the variable value and click OK 環境変数追加.png

Reboot the command line and hit the same command again to see if you can build

Recommended Posts

What to do if build from command line fails in Android development environment
What to do if password authentication fails in Docker/Postgres
Install lsb_release from the command line when lsb_release fails in docker environment
What to do if mvn archetype: generate fails
What to do if ffi installation fails when launching an application in Rails
What to do if the debug gem installation fails
What to do if TextToSpeech doesn't work on Android 11
What to do if Command line is too long appears when building a gradle project in Intellij IDEA
What to do if Failure / Error: require File.expand_path ('../ config / environment', __dir__) appears in RSpec
What to do if you get a java.io.IOException in GlassFish
What happened in "Java 8 to Java 11" and how to build an environment
What to do if the adb command cannot be executed
What to do if you can't use the rails command
[Rails] What to do if you accidentally install bundle in the production environment in your local environment
What to do if you get a gcc error in Docker
[Rails] What to do if data is not registered in DB
If you want to change the Java development environment from Eclipse
What to do if the Rails page doesn't appear in Rails tutorial 1.3.2
What to do if Cloud9 is full in the Rails tutorial
What to do if you get a DISPLAY error in gym.render ()
What to do if you forget the root password in CentOS7
What to do if you get a JNI shared library error when trying to build in Eclipse
What to do if you get a groovy warning in Thymeleaf Layout
What to do if the prefix c is not bound in JSP
What to do if you can't install the plugin from the Eclipse marketplace
I tried to build a Firebase application development environment with Docker in 2020
What to do if deployment fails on Heroku (Ruby app not detected)
What to do if tomcat process remains when tomcat is stopped in eclipse
What to do if Operation not permitted is displayed when you execute a command in the terminal
What to do if you install Ubuntu
What to do if the build fails with the error "Module compiled with Swift x.x.x cannot be imported by the Swift x.x.x compiler"
What to do if the changes are not reflected in the jar manifest file
What to do if Docker Desktop fails to launch on your M1 MacBook Pro
What to do if the server tomcat dies
What to do if you push incorrect information
What to do when IllegalStateException occurs in PlayFramework
Install lsb_release from the command line when lsb_release fails in docker environment
What to do when ‘Could not find’ in any of the sources appears in the development environment with Docker × Rails × RSpec
What to do if you can't find the JDK you put in SDKMAN after migrating from bash to zsh on macOS
What to do if you get a wrong number of arguments error in binding.pry
What to do if you can't get the text of an element in Selenium
What to do when build fails by rbenv install / pyenv install with anyenv (Debian system)
What Android, Kotlin beginners did in a month and what they were able to do
What to do if Android Studio says "your CPU doesn't support vt-x or svm"
What to do if you cannot execute with the command "Java package name / class name"
Android development, brightness adjustment in HSV from RGB color,
What to do if the Rails server can't start
What to do if ClassNotFoundException occurs when starting Tomcat
What to do if rails server can't be stopped
Build Docker + Laravel PHP + Vue.js development environment in 5 minutes
What to do if you accidentally create a model
What to do if an ActionController :: UnknownFormat error occurs
Command memo to install xeyes in ubuntu docker environment
How to build Java development environment with VS Code
Try to build a Java development environment using Docker
<Dot installation> What to do if you cannot proceed due to an error when building a development environment for Rails learning.
I tried to explain what you can do in a popular language for web development from a beginner's point of view.
What to do if you don't see the test code error message in the terminal console
What to do if you change the Listen Address from the settings screen with Mattermost docker
What to do when a could not find driver appears when connecting to a DB in a Docker environment
What to do if you get a "302" error in your controller unit test code in Rails