0

I just started a new gluon mobile multi view project with FXML and tried to run it before changing anything (apart from updating the jfxmobile-plugin version in the build.gradle file from 1.2.0 to 1.3.2). it works fine on desktop, but when i try to run the androidinstall gradle task (with my android phone connected) it fails. It gives me the following error:

:mergeClassesIntoJar
:shrinkMultiDexComponents
:createMainDexList
:writeInputListFile
[ant:java] Java Result: 1
:dex FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':dex'.
> org.gradle.api.GradleException (no error message)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

my build.gradle file:

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

apply plugin: 'org.javafxports.jfxmobile'

repositories {
    jcenter()
    maven {
        url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
    }
}

mainClassName = 'com.gluonapplication.GluonApplication'

dependencies {
    compile 'com.gluonhq:charm:4.2.0'
}

jfxmobile {
    downConfig {
        version = '3.1.0'
        // Do not edit the line below. Use Gluon Mobile Settings in your project context menu instead
        plugins 'display', 'lifecycle', 'statusbar', 'storage'
    }
    android {
        manifest = 'src/android/AndroidManifest.xml'
    }
}

operating system: Windows 10.

Please let me know if any additional information is needed to determine the cause of the problem. Thank you.

gradlew --info android log:

http://pastebin.com/yNZbZcVk

JDK version

ItachiUchiha
  • 36,135
  • 10
  • 122
  • 176
Jonathan
  • 87
  • 11
  • Can you run `gradlew.bat --info android` and post the log? – José Pereda Feb 02 '17 at 21:09
  • Thank you for the quick reply. I have added the log in my post (used pastebin due to the character limit on this site). I have also followed the proposed solution in this post http://stackoverflow.com/questions/30473854/error-after-running-the-default-gluon-project-dex-failed with no luck. – Jonathan Feb 02 '17 at 21:40
  • You are running a 32 bits JDK version on a 64 bits OS, aren't you? Can you try a 64 bits JDK? – José Pereda Feb 02 '17 at 21:53
  • 1
    If you can't switch JDKs, can you add to the `android` block this: `android { ... dexOptions { javaMaxHeapSize '1g' } ... }` and try again? – José Pereda Feb 02 '17 at 22:00
  • See your log, you are using `'C:\Program Files (x86)\Java\jdk1.8.0_101\bin\java.exe'`! Probably you need to update your JAVA_HOME? – José Pereda Feb 02 '17 at 22:06
  • that did the trick (the heap maxheapsize thing). Thank you very much ! i will see if my JAVA_HOME is wrong. – Jonathan Feb 02 '17 at 22:06

1 Answers1

1

Based on your log, I noticed you were using a 32 bits JDK on a 64 bits OS:

Starting process 'command 'C:\Program Files (x86)\Java\jdk1.8.0_101\bin\java.exe''. Working directory: D:\Android_Projects\GluonMobile-MultiViewProjectwithFXML Command: C:\Program Files (x86)\Java\jdk1.8.0_101\bin\java.exe ...

By default, the jfxmobile plugin sets 2 GB for the JVM Xmx option on Android, and considering that on a 32 bits OS that won't be possible to allocate, the solution is setting a lower value.

Based on this line of code, you can set:

android { 
     dexOptions { 
          javaMaxHeapSize '1g' 
     }
}

Or maybe a little bit more (1.5g or so?).

Note that this will be solved if you use a 64 bits JDK. Make sure you update your JAVA_HOME environment variable accordingly, as you won't need to reduce the memory for your process.

José Pereda
  • 44,311
  • 7
  • 104
  • 132
  • I had JDK 32 and 64 bit installed. Got rid of the 32 bit JDK and now it works without lowering heap size. Thanks again. – Jonathan Feb 02 '17 at 22:31