0

When I use the gradle task to create an android .apk file it outputs it the the build\javafxports\android folder of the project (both the regular and unaligned files). I couldn't find a setting to change the output folder.

When I export a jar in eclipse I can specify a destination folder. How can I do that with apk files too?

Here is my build.gradle file:

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.**.*'
        ]
    }
}
Mark
  • 2,167
  • 4
  • 32
  • 64
  • Have you tried [this](http://stackoverflow.com/questions/22833297/how-to-define-apk-output-directory-when-using-gradle#23280937)? – Miro Markaravanes Nov 10 '16 at 00:42
  • @MiroMarkaravanes thanks but the syntax seems different from what I have. can you help me convert it? I added my gradle file. – Mark Nov 10 '16 at 00:46

2 Answers2

1

The jfxmobile plugin allows changing the path where the apk will be created.

Use 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'
    }
}

Be aware that the folder should exist before running android task. Currently the plugin manages that for the default installation folder (removing it, and the apk, if exists and creating it again on every run). So you have to do it yourself, otherwise the task will skip it.

EDIT

The list of global variables that are intended to be modified if necessary are here, but the full list of variables currently included in the plugin can be found in the plugin source code.

Variables like installDirectory are used internally by the plugin and they are initialized with a default value, perform some actions like deleting the previous directory and creating it again (so Gradle performs the task). In case of overriding, these actions won't be executed, so you should take care of that yourself (or create a task for that).

José Pereda
  • 44,311
  • 7
  • 104
  • 132
  • thanks. is that option supposed to be listed here http://docs.gluonhq.com/charm/4.1.0/#_properties_3? – Mark Nov 10 '16 at 15:07
  • No, it is not listed there, as it is not initially intended to be overridden. That's why you have to take care of removing it's content. – José Pereda Nov 10 '16 at 15:10
  • ok. is there a list then of all the options somewhere? like how did you know about that one? i prefer to read than ask every single thing. – Mark Nov 10 '16 at 15:15
  • Go to the source... It is open! [Here](https://bitbucket.org/javafxports/javafxmobile-plugin/src/3c05cb8ea7e131f82b650bf87e1721aac897987e/src/main/groovy/org/javafxports/jfxmobile/plugin/android/AndroidExtension.groovy?at=default&fileviewer=file-view-default) you can find all the global variables that you can modify externally on your script. Some of them are intended for that and are listed in the documentation. – José Pereda Nov 10 '16 at 15:19
0

This works for the standard android plugin to change the directory of the generated APKs:

android {
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            output.outputFile = file("/some/dir/" + variant.name + "/" + archivesBaseName + ".apk")
        }
    }
}
Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134