I am developing an Android App in Android Studio. Not quite sure what went wrong. I was successfully building a few days ago. Any help would be great.
Here is the error:
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
Here is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "21.1.2"
defaultConfig {
multiDexEnabled true
applicationId "com.tubbs.citychurchob"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:cardview-v7:23.1.0'
compile 'com.parse.bolts:bolts-android:1+'
compile 'com.android.support:recyclerview-v7:23.1.0'
}
This may happen if you are using Android+Lambdas. Sometimes I can use Lambdas without any issues but in other situations the project won't compile and gives the exception in the compiler (When I try to pass a Lambda or a method reference to ScheduledExecutorService.scheduleAtFixedRate).
There is a discussion in this link (https://bugs.openjdk.java.net/browse/JDK-8169759) where they explain why this happen. In the mean time I'm just using lambdas in my Android project when the compiler allows me.
I had this error when I tried to use retrolambda inside my unit tests. I didn't find a solution how to make retrolambda work with unit tests. So, I use old fashioned anonymous classes instead of lambdas with my unit tests, and it works for me.
In Android Studio open:
File > Project Structure
and check if JDK location points to your JDK 1.8 directory.Note: you can use
compileSdkVersion 24
. It works trust me. For this to work first download latest JDK from Oracle.Set JDK location in project settings
Update (06/05/2017)
I wanted to use Realm for Android and that required Retrolambda. Problem is Retrolambda conflicts with Jack.
So I removed my Jack options config from my gradle shown in original answer below and made the following changes:
and
Tools.jar
If you made those changes above and you still get the following error:
Try removing the following file:
Then:
All the changes fixed it for me.
Note:
I am not sure what tools.jar does or whether it's important. Like other uses in this Stackoverflow question:
Can't build Java project on OSX yosemite
We were unfortunate enough to have to use AUSKey (some ancient dinosaur Java authentication key system used by Australian Government to authenticate our computer before we can log into Australian business portal website).
My speculation is
tools.jar
might have been a JAR file for/by AUSKey.If you're worried, instead of deleting this file, you can make a backup of the whole folder and save it somewhere just in case you can't login to Australian Business Portal again.
Hope that helps :D
Original Answer
I came across this problem today (27/06/2016).
I downloaded Android Studio 2.2 and updated JDK to 1.8.
In addition to the above answers of pointing to the correct JDK path, I had to additionally specify the JDK version in my
build.gradle(Module: app)
file:The resulting file looks like this:
Please also notice if you came across an error about
Java 8 language features requires Jack enabled
, you need to add the following to your gradle file (as shown above):After doing that, I finally got my new project app running on my phone.
This is because your $JAVA_HOME is not set. If you are using a Mac:
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home"
in .bash_profile