我尝试创建 Android APK 时遇到Execution failed for task ':ChatAppGluonApp:applyRetrobuffer'.
。我正在使用 Eclipse Oxygen (4.7.3RC2) 和 Windows 7。MacOs 10.13.1 和 Eclipse Oxygen (4.7.2) 也会出现同样的错误。在这两个操作系统上,我都使用 Android 26 和 Build Tools 26.0.2。
我尝试使用 Java 8 和 9 运行,但结果是相同的。该程序在桌面上运行良好。
buildscript {
repositories {
jcenter()
google()
maven{
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
dependencies {
classpath 'org.javafxports:jfxmobile-plugin:2.0.17'
}
}
apply plugin: 'org.javafxports.jfxmobile'
repositories {
jcenter()
maven {
url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
}
}
mainClassName = 'de.....ChatApplication'
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile 'com.gluonhq:charm:4.4.0-jdk9'
androidRuntime 'com.gluonhq:charm:4.4.1'
compile 'com.airhacks:afterburner.mfx:1.6.3'
compile files('libs/chatFx.jar')
//compile files('libs/chatFxTest.jar')
compile files('libs/miglayout-core-5.0.jar')
compile files('libs/miglayout-javafx-5.0.jar')
// https://mvnrepository.com/artifact/org.slf4j/slf4j-api
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
// https://mvnrepository.com/artifact/com.google.code.findbugs/jsr305
compile group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.2'
// https://mvnrepository.com/artifact/javax.xml.ws/jaxws-api
compile group: 'javax.xml.ws', name: 'jaxws-api', version: '2.2.6'
}
jfxmobile {
downConfig {
version = '3.7.0'
// Do not edit the line below. Use Gluon Mobile Settings in your project context menu instead
plugins 'display', 'lifecycle', 'statusbar', 'storage'
}
android {
compileSdkVersion = '26'
buildToolsVersion = '26.0.2'
manifest = 'src/android/AndroidManifest.xml'
}
ios {
infoPList = file('src/ios/Default-Info.plist')
forceLinkClasses = [
'com.gluonhq.**.*',
'javax.annotations.**.*',
'javax.inject.**.*',
'javax.json.**.*',
'org.glassfish.json.**.*'
]
}
}
最佳答案
基于 applyRetrobuffer
任务的异常:
15:26:29.974 [ERROR] [system.err] java.lang.IllegalArgumentException
15:26:29.974 [ERROR] [system.err] at org.objectweb.asm.ClassReader.<init>(Unknown Source)
15:26:29.974 [ERROR] [system.err] at org.objectweb.asm.ClassReader.<init>(Unknown Source)
15:26:29.974 [ERROR] [system.err] at org.javafxports.retrobuffer.ClassAnalyzer.analyze(ClassAnalyzer.java:48)
15:26:29.974 [ERROR] [system.err] at org.javafxports.retrobuffer.Retrobuffer$1.visitClass(Retrobuffer.java:59)
15:26:29.974 [ERROR] [system.err] at org.javafxports.retrobuffer.ClasspathVisitor.visitFile(ClasspathVisitor.java:59)
15:26:29.974 [ERROR] [system.err] at org.javafxports.retrobuffer.ClasspathVisitor.visitFile(ClasspathVisitor.java:41)
15:26:29.974 [ERROR] [system.err] at java.base/java.nio.file.Files.walkFileTree(Files.java:2713)
15:26:29.974 [ERROR] [system.err] at java.base/java.nio.file.Files.walkFileTree(Files.java:2785)
15:26:29.974 [ERROR] [system.err] at org.javafxports.retrobuffer.Retrobuffer.run(Retrobuffer.java:56)
15:26:29.975 [ERROR] [system.err] at org.javafxports.retrobuffer.Main.main(Main.java:45)
Android 不支持 Java 9,因此使用 jfxmobile 2.0.+ 时,所有 Android 依赖项都必须使用 Java 8 目标进行编译。
在您的情况下,异常表明类路径上至少还有一个类已使用 java 9 或更高版本作为目标进行编译。
已经有一个归档 issue显示有关产生失败的类的更多信息。
我不能说你的本地依赖项,但其余的对我来说工作得很好。至于miglayout-*-5.0
,除非你编译过本地版本,否则是2014年的。
无论如何,只需确保将其添加到您使用 Java 9 自己构建的任何本地依赖项中即可:
sourceCompatibility = 1.8
targetCompatibility = 1.8
顺便说一句,当您成功应用retrobuffer任务时,您将与依赖项中的重复文件发生一些冲突,例如META-INF/LICENSE.txt
位于不同的jar中。使用 packagingOptions
,例如 link .
关于Gluon Mobile androidinstall applyRetrobuffer 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49409495/