Running my application in Android Emulator, I faced this error:
error:execution failed for task ':app:compiledebugjavawithjavac'.
My application got build up and ran in the emulator despite ignoring this issue. However, running it on my USB connected device was not a success.
Here’s how it is fixed. It demanded the environment variable
JAVA_HOME to be set up. Open up your
.bashrc file in your favorite editor. Add
export JAVA_HOME="/path/to/your/jdk/installation" to the end of this file. I set the value to
/usr/lib/jvm/java-1.8.0-openjdk-amd64. This set up the
JAVA_HOME for me.
.gradle directory in the application directory needs to be deleted and then go to
Build > Make Project in the Android Studio menu. This builds up the application’s fresh
.gradle directory. And
Run your application successfully.