javaFX gradle plug-in, how to retrolambda your existing jar file

162 views
Skip to first unread message

Jonathan Serranyaw

unread,
Jun 15, 2015, 1:14:59 AM6/15/15
to javafx...@googlegroups.com
i am building an apk ,the build.gradle below allows me to make an apk from a pre-compiled and dependency-self-contained javaFX jar file,

buildscript {
    repositories {
        jcenter()
    }
 
    dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.0.0-b9'
    }
}

apply plugin: 'org.javafxports.jfxmobile'

mainClassName = 'mobileView.Main'
version = '8u40'

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

repositories {
    jcenter()
}

jfxmobile {
    ios {
        forceLinkClasses = ['javafxapp.**.*']
    }
    android {
        applicationPackage = 'com.sample.sample'
    }
}

the file structure of solution is like this

[gradle project root]
   build.gradle
   [libs]
      javaFXapp.jar
   [build]
      (build files, apk etc...)

obviously this would skip any compile step as i have no [src] folder, the script above would successfully create an apk file.

THE PROBLEM

the problem is, if the pre-compiled jar file would contain java 8 lambda expressions in its byte code, the :dex would fail, seeing that the :retrolambda task/step is skipped on console because graddle didn't compile the classes or the javaFXapp.jar.
my question is how to i do this script correctly? or how to i tell graddle to :retrolambda my current jar file 

Jonathan Serranyaw

unread,
Jun 15, 2015, 1:36:00 AM6/15/15
to javafx...@googlegroups.com
[UPDATE]

here is the console of how the build failed, it is :createMainDexList that failed not :dex

C:\fx\java dss>gradle android
Picked up _JAVA_OPTIONS: -Xmx1024M
:compileJava UP-TO-DATE
:compileRetrolambdaMain SKIPPED
:processResources UP-TO-DATE
:classes UP-TO-DATE
:compileAndroidJava UP-TO-DATE
:compileRetrolambdaAndroid SKIPPED
:compileTestJava UP-TO-DATE
:compileRetrolambdaTest SKIPPED
:compileRetrolambda UP-TO-DATE
:mergeClassesIntoJar
:validateManifest
:collectMultiDexComponents
:shrinkMultiDexComponents
:createMainDexList
[ant:java] Java Result: 1
:createMainDexList FAILED

FAILURE: Build failed with an exception.

------
the main cause of failure is 
------
> Exception in thread "main" com.android.dx.cf.iface.ParseException: InvokeDynam
ic not supported
...
  ...while preparsing cst 0035 at offset 000000f1
  ...while parsing jfxtras/labs/internal/scene/control/skin/BigDecimalFieldSkin.class

i tried modifying grade built by adding this but it did not help

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar') 
    runtime fileTree(dir: 'libs', include: '*.jar')
}



Joeri Sykora

unread,
Jun 15, 2015, 1:55:06 AM6/15/15
to Jonathan Serranyaw, javafx...@googlegroups.com

The plugin does currently not support applying retrolambda to dependent libraries. You'll have to make sure that you apply retrolambda to those dependencies yourself. If you don't own the package, you could still do this if the source of the package is public, by downloading the source and updating their build procedure by applying retrolambda somehow. As far as I know, retrolambda has support for at least gradle and maven.

We might want to add this feature to the plugin itself in the future, making it possible to somehow declare which dependencies should have retrolambda applied as well.

Op 15-jun.-2015 07:36 schreef "Jonathan Serranyaw" <miming...@gmail.com>:
--
You received this message because you are subscribed to the Google Groups "JavaFXAndroid" group.
To unsubscribe from this group and stop receiving emails from it, send an email to javafxandroi...@googlegroups.com.
To post to this group, send email to javafx...@googlegroups.com.
Visit this group at http://groups.google.com/group/javafxandroid.
To view this discussion on the web visit https://groups.google.com/d/msgid/javafxandroid/60c94992-1143-4037-a6a3-305a75ed790a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jonathan Serranyaw

unread,
Jun 15, 2015, 2:31:24 AM6/15/15
to javafx...@googlegroups.com, miming...@gmail.com
thanks for the reply, my problem is actually easy to solve, all of my 3rd party dependencies are free of lambda expressions, the only library containing lambda expressions is the jfxtras library, but it looks like i'll be getting rid of it soon because java 8u45 now supports spinners. i temporarily used jfxtras spinner during pre-java 8u40 period

Jonathan Serranyaw

unread,
Jun 16, 2015, 4:23:16 AM6/16/15
to javafx...@googlegroups.com
another thing devs must be warned by doing this approach, your javaFX jar file must target JDK 7 bytecode, or else you have problems while dexing your jars

Dino Quimson

unread,
Jun 16, 2015, 11:37:59 PM6/16/15
to javafx...@googlegroups.com
I encountered this problem before, I solved it using Gluon Plugin. I also upgraded my old Windows XP to Window 8. Hope this helps!
Reply all
Reply to author
Forward
0 new messages