sample java
sample java

Reputation: 1

Converting JavaFX to Android using gradlew

I am new to JavaFX, and I am trying to convert to Android apk using the javafxmobile plugin.
While converting to Android by using gradlew, I am getting an error like Execution failed for task ':dex'.
My system has the JDK 1.8u40 installed and gradle is configured with it.
I also tried using the Dalvik SDK, but its still not converting.

Here is the complete error:

C:\Users\Vss\Documents\NetBeansProjects\andyTest>gradlew android
:compileJava UP-TO-DATE
:compileRetrolambdaMain UP-TO-DATE
: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
:dex
[ant:java] Java Result: 1
:dex FAILED

FAILURE: Build failed with an exception.

When I ran with --stacktrace, I got the following error details:

C:\Users\Vss\Documents\NetBeansProjects\andyTest>gradlew -stacktrace android
:compileJava UP-TO-DATE
:compileRetrolambdaMain UP-TO-DATE
: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
:dex
[ant:java] Java Result: 1
:dex FAILED

FAILURE: Build failed with an exception.

my build.gradle file as follows:

    task wrapper(type: Wrapper) {
    gradleVersion = '2.3'
    }
    buildscript {
    repositories {
        jcenter()
    }

    dependencies {

        classpath 'org.javafxports:jfxmobile-plugin:1.0.0-b9'
        classpath 'org.codehaus.groovy:groovy-backports-compat23:2.3.5'


    }
    }

    apply plugin: 'org.javafxports.jfxmobile'


    mainClassName = 'andytest.andyTest'

    version = '8u40'

   repositories {
    jcenter()
   }


   jfxmobile {

    android {

    applicationPackage = 'andytest.andyhere'




    }
    }

Upvotes: 0

Views: 750

Answers (3)

Shersha Fn
Shersha Fn

Reputation: 1571

I had the same problem now it's solved .Now I am able to compile and make my android apk .

So these are the steps I followed

  1. Make sure you have updated your sdk manager -> support library to latest version (23.1.1) it was the latest for me when I posted this answer. This will update

H:\sdk\extras\android\support\multidex files

  1. Set environment variable name _JAVA_OPTIONS with value -Xmx1024M
  2. Make sure you add your android sdk location in build.gradle androidSdk='H:/ADT BUNDLE/sdk'

like this

buildscript {
    repositories {
        jcenter()
    }
    dependencies {

           classpath 'org.javafxports:jfxmobile-plugin:1.0.0-b9'


    }
}

apply plugin: 'org.javafxports.jfxmobile'


repositories {
    jcenter()
}

mainClassName = 'com.fff.Fff'

jfxmobile {
    android {
        manifest = 'src/android/AndroidManifest.xml'
        androidSdk='H:/ADT BUNDLE/sdk'

    }
}

Upvotes: 0

If you have done anything like that then please provide me the details of how you have done that. which IDE did you use to create JAVA FX project and how u converted to Android App.

I'm using Netbeans to create the project. And trying to convert that to Android Project

Upvotes: 0

Viktor Çitaku
Viktor Çitaku

Reputation: 11

I had the same problem, you are missing this directory to your android studio:

..\Android\sdk\extras\android\support\multidex

Here is an example I have made my self: https://github.com/viktorcitaku/JavaFXAndroid

Upvotes: 1

Related Questions