Code Monkey home page Code Monkey logo

Comments (15)

stepango avatar stepango commented on June 29, 2024 7

My solution for it.

String java8 = getJavaVersion(8)
String java7 = getJavaVersion(7)
retrolambda {
    jdk java8 //have tried with JAVA8_HOME
    oldJdk java7 //have tried with JAVA6_HOME
    javaVersion JavaVersion.VERSION_1_7 //have matched the above with VERSION_1_6
}

String getJavaVersion(Integer v) {
  def sout = new StringBuffer()
  def proc = "/usr/libexec/java_home -v 1.$v".execute()
  proc.consumeProcessOutput(sout, new StringBuffer())
  proc.waitForOrKill(1000)
  return sout.toString().replace("\n", "").replace("\r", "")
}

from gradle-retrolambda.

pakoito avatar pakoito commented on June 29, 2024 1

I found a workaround by going to Android Studio -> Preferences -> Path Variables and adding

JAVA_8 /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home

from gradle-retrolambda.

MaximusMcCann avatar MaximusMcCann commented on June 29, 2024

Unfortunately this didn't fix the above error for me. Any other steps you may have done?
Android Studio 0.9.2, Gradle 2.1, OSX

image
image

retrolambda {
    jdk System.getenv("JAVA_8") //have tried with JAVA8_HOME
    oldJdk System.getenv("JAVA7_HOME") //have tried with JAVA6_HOME
    javaVersion JavaVersion.VERSION_1_7 //have matched the above with VERSION_1_6
    jvmArgs '-arg1', '-arg2'
}

Same error

Error:Execution failed for task ':proj:patchAndroidJar'.
> Retrolambda: null/jre/lib/rt.jar does not exist, make sure that the environment variable JAVA_HOME or JAVA8_HOME, or the gradle property retrolambda.jdk points to a valid version of java8.

from gradle-retrolambda.

MaximusMcCann avatar MaximusMcCann commented on June 29, 2024

Below is my current, ugly-hardcoded, solution :(

retrolambda {
    jdk '/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home'//System.getenv("JAVA_8")
    oldJdk System.getenv("JAVA7_HOME")
    javaVersion JavaVersion.VERSION_1_7
}

from gradle-retrolambda.

mrjohannchang avatar mrjohannchang commented on June 29, 2024

Please check this if it is helpful: http://stackoverflow.com/a/27795843/1592410

from gradle-retrolambda.

z-br avatar z-br commented on June 29, 2024

On OSX we had to use @stepango 's VERY CREATIVE workaround. Thanks for your snippet, it just ended an hour of nonsense for us. This is pretty crazy! Tried setting environment variables every way under the sun and couldn't get anything working. Tried the .bashrc the .bash_profile the /etc/profile the .profile , Path Variables in Android Studio etc. Seems like it shouldn't be this hard.

from gradle-retrolambda.

free5ty1e avatar free5ty1e commented on June 29, 2024

Ditto: On OSX we had to use @stepango 's VERY CREATIVE workaround.
THANK YOU!! This is also preferable to us as we want to have Jenkins CI automated builds, and this workaround only requires that one install JDK8 before utilizing. Very modular. :D

from gradle-retrolambda.

mtrewartha avatar mtrewartha commented on June 29, 2024

Thanks @stepango, worked for us!

from gradle-retrolambda.

andersmurphy avatar andersmurphy commented on June 29, 2024

I have another work around for this issue, that might be helpful. We couldn't use @stepango workaround as our projects has a variety of development machines and a CI server. Our solution uses a gradle.properties file and is outlined in this blog post:

http://andersmurphy.com/2015/09/16/setting-up-retrolambda/

Hope that helps.

from gradle-retrolambda.

Mithrandir21 avatar Mithrandir21 commented on June 29, 2024

@andersmurphy The guide you provided worked great! Thank you for the hard work.
Wanted to make a simple suggestion.
Maybe make the following part a bit more clear as it can be confusing for some users:
"Note: If you are building your project with Java 8 you only need to add oldJdk JAVA7_HOME. If you are building your project with Java 7 you only need to add jdk JAVA8_HOME."

Thanks again and keep up the wonderful work.

from gradle-retrolambda.

andersmurphy avatar andersmurphy commented on June 29, 2024

@Mithrandir21 Good to hear it worked for you and thanks for the feedback. I'll try and clear that confusing section up.

from gradle-retrolambda.

logrish avatar logrish commented on June 29, 2024

@andersmurphy Thanks buddy... looks like this is the only thing that works with macosx :(
Thanks again 👍

from gradle-retrolambda.

zhangxiaofan918 avatar zhangxiaofan918 commented on June 29, 2024

thanks so much~~!

from gradle-retrolambda.

azgul avatar azgul commented on June 29, 2024

Editing /etc/environment as follows and rebooting Ubuntu made it work for me. Otherwise Gradle wouldn't pick up the environment variables, not sure why.
$ cat /etc/environment
JAVA_HOME=/usr/lib/jvm/java-8-oracle
JAVA7_HOME=/usr/lib/jvm/java-7-oracle
JAVA8_HOME=/usr/lib/jvm/java-8-oracle

from gradle-retrolambda.

Rock610 avatar Rock610 commented on June 29, 2024

@stepango worked for me thanks!

from gradle-retrolambda.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.