I am porting a JavaFX application to Android using JavaFXPorts. However, assuming I understand this error correctly, I need to perform a multi-dex build. This is not surprising, since the project has many dependencies.
./gradlew :client:android
...
:client:dex[ant:java] Java Result: 2
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':client:dex'.
> UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Too many classes in --main-dex-list, main dex capacity exceeded
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:546)
at com.android.dx.command.dexer.Main.runMultiDex(Main.java:366)
at com.android.dx.command.dexer.Main.run(Main.java:275)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
I followed the instructions for configuring the multi-dex build, but it does not appear to be compatible with JavaFXPorts. Specifically, when I add this to my build.gradle:
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
I get the following error:
./gradlew :client:android
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\username\myproject\client\build.gradle' line: 67
* What went wrong:
A problem occurred evaluating root project 'client'.
> Could not find method compileSdkVersion() for arguments [21] on object of type org.javafxports.jfxmobile.plugin.android.AndroidExtension.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
For reference, my build.gradle is as follows:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.0.8'
}
}
apply plugin: 'base'
subprojects {
apply plugin: 'scala'
apply plugin: 'org.javafxports.jfxmobile'
repositories {
jcenter()
mavenCentral()
}
dependencies {
...
}
mainClassName = "com.myproject.client.Main"
jfxmobile {
ios {
forceLinkClasses = [ 'com.myproject.client.**.*' ]
}
android {
// This does not work with JavaFXPorts
/*compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
minSdkVersion 14
targetSdkVersion 21
// Enabling multidex support.
multiDexEnabled true
}*/
packagingOptions {
pickFirst 'META-INF/LICENSE.txt'
pickFirst 'META-INF/NOTICE.txt'
pickFirst 'reference.conf'
pickFirst 'rootdoc.txt'
}
}
}
}
How can I configure a multi-dex build for a JavaFXPorts project?