I am trying to make my application run on an android device by using the jfxmobile-plugin.
When I do a
gradle android
on my project I get
Execution failed for task ':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)
My gradle file is this
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:1.3.2'
}
}
apply plugin: 'org.javafxports.jfxmobile'
mainClassName = 'de.package.of.application.ClientApp'
dependencies {
compile 'com.annimon:stream:1.0.1'
compile 'com.jakewharton.threetenabp:threetenabp:1.0.4'
compile 'com.gluonhq:charm:4.2.0'
androidRuntime 'com.gluonhq:charm-android:3.0.0'
iosRuntime 'com.gluonhq:charm-ios:3.0.0'
desktopRuntime 'com.gluonhq:charm-desktop:3.0.0'
compile fileTree(dir: 'target/dependencies', include: '*.jar')
runtime fileTree(dir: 'target/dependencies', include: '*.jar')
}
repositories {
jcenter()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
jfxmobile {
ios {
forceLinkClasses = ['ensemble.**.*']
}
android {
//manifest = 'AndroidManifest.xml'
compileSdkVersion = '24'
androidSdk='C:/Tools/android-sdk-windows'
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
//... some more excludes
}
dexOptions {
javaMaxHeapSize '3g'
// keepRuntimeAnnotatedClasses false
}
}
}
I found some similar questions about the exception logged by the gradle build but non brought a real solution for me so far especially in combination with the usage of the javafxports-plugin.
- Some suggested to set the compileSdkVersion to a minumum of 21-> I use 24 -> this does not help.
- Using keepRuntimeAnnotatedClasses=false is not an option because the application is build on some Reflection/injection-logic (spring-framework).
- As I understand the build process takes those classes into account to put in the main-dex-file which are required to initially start up the application. So I stripped down the application to an absolut minimum with no other dependencies (direct or transitive) to the other libraries of my application (no imports of classes from other libraries, except to java/javafx). The other libraries are included by the 'runtime fileTree...' part of the gradle-file but are not really used at startup. Idea was to create a 2-phase startup of the application: First a minimum-app and then, when the minimum app is loaded, start the real application code. -> no success, it seems all libraries are taken into account for the main-dex-file.
I do not see how to solve it together with javafxports. Does anyone have suggestions?