Retrolambda on Travis CI

849 views Asked by At

My travis.yml file:

language: android

jdk: oraclejdk8

android:
  components:
    - build-tools-22.0.1
    - android-22
    - extra-android-m2repository

script:
    - gradle build connectedCheck

It fails during app:compileRetrolambdaDebug with error message Process 'command '/usr/lib/jvm/java-8-oracle/bin/java'' finished with non-zero exit value 1.

Is it possible to run Retrolambda on Travis CI?

After adding --debug parameter, I got following information:

13:44:02.064 [INFO] [system.out] Error! Failed to transform some classes
13:44:02.073 [INFO] [system.out] java.lang.RuntimeException: java.lang.IllegalAccessException: no such method: cz.skaut.warehousemanager.fragment.ItemDetailFragment.lambda$onViewCreated$32(Bitmap)void/invokeSpecial
at net.orfjackal.retrolambda.lambdas.LambdaReifier.reifyLambdaClass(LambdaReifier.java:42)
at net.orfjackal.retrolambda.lambdas.BackportLambdaInvocations$InvokeDynamicInsnConverter.backportLambda(BackportLambdaInvocations.java:105)
at net.orfjackal.retrolambda.lambdas.BackportLambdaInvocations$InvokeDynamicInsnConverter.visitInvokeDynamicInsn(BackportLambdaInvocations.java:94)
at net.orfjackal.retrolambda.asm.ClassReader.readCode(ClassReader.java:1439)
at net.orfjackal.retrolambda.asm.ClassReader.readMethod(ClassReader.java:1017)
at net.orfjackal.retrolambda.asm.ClassReader.accept(ClassReader.java:693)
at net.orfjackal.retrolambda.asm.ClassReader.accept(ClassReader.java:506)
at net.orfjackal.retrolambda.Transformers.lambda$transform$4(Transformers.java:106)
at net.orfjackal.retrolambda.Transformers$$Lambda$2/1190900417.accept(Unknown Source)
at net.orfjackal.retrolambda.Transformers.transform(Transformers.java:120)
at net.orfjackal.retrolambda.Transformers.transform(Transformers.java:106)
at net.orfjackal.retrolambda.Transformers.backportClass(Transformers.java:46)
at net.orfjackal.retrolambda.Retrolambda.run(Retrolambda.java:72)
at net.orfjackal.retrolambda.Main.main(Main.java:26)
13:44:02.086 [INFO] [system.out] Caused by: java.lang.IllegalAccessException: no such method: cz.skaut.warehousemanager.fragment.ItemDetailFragment.lambda$onViewCreated$32(Bitmap)void/invokeSpecial
at java.lang.invoke.MemberName.makeAccessException(MemberName.java:872)
at java.lang.invoke.MemberName$Factory.resolveOrFail(MemberName.java:993)
at java.lang.invoke.MethodHandles$Lookup.resolveOrFail(MethodHandles.java:1379)
at java.lang.invoke.MethodHandles$Lookup.findSpecial(MethodHandles.java:997)
at net.orfjackal.retrolambda.lambdas.Types.toMethodHandle(Types.java:42)
at net.orfjackal.retrolambda.lambdas.Types.asmToJdkType(Types.java:19)
at net.orfjackal.retrolambda.lambdas.LambdaReifier.callBootstrapMethod(LambdaReifier.java:106)
at net.orfjackal.retrolambda.lambdas.LambdaReifier.reifyLambdaClass(LambdaReifier.java:37)
... 13 more
13:44:02.089 [INFO] [system.out] Caused by: java.lang.NoClassDefFoundError: android/support/v4/view/LayoutInflaterFactory
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:455)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:367)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at net.orfjackal.retrolambda.NonDelegatingClassLoader.loadClass(NonDelegatingClassLoader.java:25)
at java.lang.invoke.MethodHandleNatives.resolve(Native Method)
at java.lang.invoke.MemberName$Factory.resolve(MemberName.java:965)
at java.lang.invoke.MemberName$Factory.resolveOrFail(MemberName.java:990)
... 19 more
13:44:02.092 [INFO] [system.out] Caused by: java.lang.ClassNotFoundException: android.support.v4.view.LayoutInflaterFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at net.orfjackal.retrolambda.NonDelegatingClassLoader.loadClass(NonDelegatingClassLoader.java:27)
... 32 more

Similar error is reported here, so it may be Gradle-retrolambda plugin issue.

1

There are 1 answers

0
Jolanda Verhoef On

After fiddling around with this for days, for me it worked by using the following .travis.yml file:

language: android
jdk:
  - oraclejdk7
  - oraclejdk8
android:
  components:
    - build-tools-22.0.1
    - android-22
    - extra-android-support
    - extra-android-m2repository
  licenses:
    - '.+'

before_install:
  - export JAVA7_HOME=/usr/lib/jvm/java-7-oracle
  - export JAVA8_HOME=/usr/lib/jvm/java-8-oracle
  - export JAVA_HOME=$JAVA7_HOME
script:
  - ./gradlew clean assemble || ./gradlew clean assemble

The most important to note is that we export JAVA_HOME as JAVA7_HOME, which I didn't see in any online examples.