Using JDK 8 in android

android
java

#1

I am using retrolambda in my Android project. But it fails to build with following message.

Execution failed for task ‘:app:compileInternalDebugJavaWithJavac’.

When running gradle with java 5, 6 or 7, you must set the path to jdk8, either with property retrolambda.jdk or environment variable JAVA8_HOME

Please suggest me any solution. My whole CI experience is suffering because of this.


#2

I also ran into the same issue, and I was able to fix it by adding the following configuration to the machine section of my circle.yml file:

machine:
    java:
        version: oraclejdk8

I believe that Circle CI builds use version 1.7.0_55 of the JDK by default (see this page: https://circleci.com/docs/language-java), so you need to explicitly tell it to use the Java 8 JDK in your circle.yml file (see above). Once I added this, my Android application - using retrolambda - built successfully.

Hope this helps!
-Matt


#3

How would you know the possible values for java version? Is there a list of values that we can use as a reference? Thanks


#4

Ooops. It’s in the documentation, values will depend on the Ubuntu version you’re using.

https://circleci.com/docs/build-image-precise/#java
https://circleci.com/docs/build-image-trusty/#java

I encountered a failed build machine.environment.java should be a string

machine:
    java:
        version: oraclejdk8

to fix this issue, I enclosed oraclejdk8 with single quote (’)

machine:
    java:
        version: 'oraclejdk8'

#5