我正在使用JavaFXPorts将JavaFX应用程序移植到Android。但是,假设我正确理解了这个错误,我需要执行multi-dex构建。这并不奇怪,因为该项目有很多依赖项。
./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
我关注instructions for configuring the multi-dex build,但它似乎与JavaFXPorts不兼容。具体来说,当我将它添加到我的build.gradle:
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
我收到以下错误:
./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
作为参考,我的build.gradle如下:
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'
}
}
}
}
如何为JavaFXPorts项目配置multi-dex构建?