如何更改生成的 apk 文件的默认输出文件夹?

How to change the default output folder for generated apk files?

当我使用 gradle 任务创建 android .apk 文件时,它会将其输出到项目的 build\javafxports\android 文件夹(常规文件和未对齐文件) ).我找不到更改输出文件夹的设置。

当我在 eclipse 中导出 jar 时,我可以指定目标文件夹。我怎样才能用 apk 文件做到这一点?

这是我的 build.gradle 文件:

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

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.0.1'
}

jfxmobile {
    downConfig {
        version = '3.0.0'
        plugins 'display', 'lifecycle', 'statusbar', 'storage'
    }
    android {
        compileSdkVersion = 24
        manifest = 'src/android/AndroidManifest.xml'
        androidSdk = 'C:/Users/Mark/AppData/Local/Android/sdk'
    }
    ios {
        infoPList = file('src/ios/Default-Info.plist')
        forceLinkClasses = [
                'com.gluonhq.**.*',
                'javax.annotations.**.*',
                'javax.inject.**.*',
                'javax.json.**.*',
                'org.glassfish.json.**.*'
        ]
    }
}

这适用于标准 android 插件 以更改生成的 APK 的目录:

android {
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            output.outputFile = file("/some/dir/" + variant.name + "/" + archivesBaseName + ".apk")
        }
    }
}

jfxmobile 插件允许更改创建 apk 的路径。

使用installDirectory:

jfxmobile {
    downConfig {
        version = '3.0.0'
        plugins 'display', 'lifecycle', 'statusbar', 'storage'
    }
    android {
        installDirectory = file('/full/path/of/custom/folder')
        manifest = 'src/android/AndroidManifest.xml'
    }
}

请注意,该文件夹应该在 运行ning android 任务之前存在。目前,该插件为默认安装文件夹管理它(删除它和 apk,如果存在并在每个 运行 上重新创建它)。所以必须自己动手,不然任务会跳过

编辑

必要时要修改的全局变量列表是 here, but the full list of variables currently included in the plugin can be found in the plugin source code

installDirectory这样的变量被插件内部使用,它们被初始化为一个默认值,执行一些操作,比如删除以前的目录并重新创建它(所以Gradle执行任务) .在覆盖的情况下,这些操作不会被执行,所以你应该自己处理(或为此创建一个任务)。