0

I work on a project from two locations and I pulled the project from Git now I work at home.

At work I see android.jar and jfx.jar(don't know the exact name) inside the external libraries in IntelliJ and the classes are available. At home however, the jars are not visible and the android classes and JFXActivity classes are not recognized as a consequence.

I don't now why Gradle doesn't load it, the build.gradle is the same.

build.gradle:

buildscript {
    repositories {
        jcenter()
        maven {
            url 'http://xxxx.com:8080/artifactory/plugins-release'
        }
    }
    dependencies {
        classpath 'org.javafxports:jfxmobile-plugin:1.0.8'
        classpath "org.jfrog.buildinfo:build-info-extractor-gradle:+"
    }
}

apply plugin: 'com.jfrog.artifactory'
apply plugin: 'org.javafxports.jfxmobile'

artifactory {
    contextUrl = "${artifactory_contextUrl}"
    publish {
        repository {
            repoKey = 'libs-release-local'
            maven = true
        }
    }
    resolve {
        repository {
            repoKey = 'libs-release'
            maven = true
        }
    }
}

repositories {
    jcenter()
    mavenLocal()
    maven {
        url 'http://nexus.gluonhq.com/nexus/content/repositories/releases'
    }
}

mainClassName = 'com.xxxx.scan.application.gluon.MainApplication'

dependencies {
    compile 'com.gluonhq:charm:2.1.1'
    compile 'com.airhacks:afterburner.mfx:1.6.2'
    androidRuntime 'com.gluonhq:charm-android:2.1.1'
    iosRuntime 'com.gluonhq:charm-ios:2.1.1'
    desktopRuntime 'com.gluonhq:charm-desktop:2.1.1'

    compile(group: 'com.essers.pxl2016', name: 'scan-server-definition', version: '0.0.1-SNAPSHOT')
    compile(group: 'com.essers.pxl2016', name: 'client', version: '1.0-SNAPSHOT')
    compile(group: 'com.essers.pxl2016', name: 'configuration', version: '1.0-SNAPSHOT')
    compile('com.google.code.gson:gson:2.2.4')
    testCompile "junit:junit:4.12"
}

task print << {
    println("$System.env.ANDROID_HOME")
}

jfxmobile {
    android {
        androidSdk = "$System.env.ANDROID_HOME"
        manifest = 'src/android/AndroidManifest.xml'
        compileSdkVersion = 21
    }
    ios {
        infoPList = file('src/ios/Default-Info.plist')
        forceLinkClasses = [
                'com.xxxx.scan.application.gluon.**.*',
                'com.gluonhq.**.*',
                'io.datafx.**.*',
                'javax.annotations.**.*',
                'javax.inject.**.*',
                'javax.json.**.*',
                'org.glassfish.json.**.*'
        ]
    }
}

test {
    exclude 'com/xxxx/scan/application/gluon/**'
}
progonkpa
  • 3,590
  • 9
  • 31
  • 50
  • Do you have defined `ANDROID_HOME`? Have you downloaded the Android SDK? You need to do it on every machine. When you run `gradlew --info android`, what error do you get? – José Pereda May 14 '16 at 16:48
  • Hi José, I have ANDROID_HOME defined in system environment variables and I know Gradle can find them because I executed a task with println("$System.env.ANDROID_HOME"). gradlew --info android shows no errors and ends with build successful and it shows that $System.env.ANDROID_HOME is resolved and I see it adds jfxrt.jar. AndroidInstall also works and the apk works with Android specific functionality included. The only thing that doesn't work is that IntelliJ doesn't add android.jar and jfxdvk.jar to external libraries. I suppose I could add the dependencies manually from .gradle cache.. – progonkpa May 14 '16 at 18:26
  • If you build and run the app, _definitely_ those dependencies are there. In IntelliJ, maybe you need to click the refresh button on the Gradle panel to update the list of dependencies. Under External Libraries you should see: android.jar, jdk1.8, charm dependencies, javax-json, jfxdvk, afterburner, robovm dependencies and your own ones. – José Pereda May 14 '16 at 18:31
  • I tried the refresh button but no luck. Charm, afterburner and 1.8 are visible under external libraries. Android.jar, jfxdvk, robovm, javax-json are not. I tried things like 'invalidate caches and restart' and I even deleted the whole .gradle directory. Gradle then imports the libraries as mentioned above. For some reason Gradle or IntelliJ doesn't react to the jfxmobile part of the script it seems. – progonkpa May 14 '16 at 19:06
  • Try this: make sure you have installed Gluon plugin for IntelliJ, create a new project, Gluon Mobile, Single View project. Check if it works and shows those dependencies – José Pereda May 14 '16 at 19:09
  • A new single page Gluon project included three external libraries: 1.8, charm:2.1.1 and javax.json:1.0.4. I don't know if this is of any importance but I have to elevate the project to java 8 manually when the project initially finishes building even though the default SDK level is 1.8. – progonkpa May 14 '16 at 19:27
  • Which is your IntelliJ version? The language level has to be set to 8, yes, it's a known issue, but it has nothing to do with the dependencies. – José Pereda May 14 '16 at 19:30
  • it's version 15.0.6 ultimate with an educational license. – progonkpa May 14 '16 at 19:39
  • You can try to set the ANDROID_HOME property in a `gradle.properties` file under your gradle home (user/.gradle). Maybe IntelliJ can't resolve the Android dependencies without that. – José Pereda May 14 '16 at 19:45
  • I had almost forgotten that I had the same problems when I started my first Gluon project. Exactly what progonkpa describes. `android.jar` and `jfxdvk.jar` is missing. After having tried all your suggestions I still need to add these dependencies manually. (Eclipse Mars 4.5.2 + efxclipse 2.3, jfxmobile-plugin:1.0.8) – jns May 15 '16 at 00:22
  • @JoséPereda I tried your suggestion but no prevail. – progonkpa May 15 '16 at 14:21
  • @jns That means the problem is not specific too IntelliJ and so it unravels a little bit more. – progonkpa May 15 '16 at 14:21
  • I've just checked on Windows, with IntelliJ 15 the jars were missing. So I've updated to 16.1.2 and Android and jfxdvk jars are included under external dependencies. Can you try updating IntelliJ? – José Pereda May 15 '16 at 14:50
  • I installed IntelliJ 2016.1.2 Community edition and I can confirm that all dependencies loaded well in a new SingleView Gluon Mobile project created by the plugin. Thank you José, you can post an answer if you like. – progonkpa May 15 '16 at 17:50

2 Answers2

0

You reference the Android SDK in this line:

androidSdk = "$System.env.ANDROID_HOME"

Make sure the SDK can be found at that location, or reference it according to the Gluon Documentation:

you have to let the jfxmobile plugin know where to look for the Android SDK installation directory using one of the following ways:

  • an androidSdk property defined under jfxmobile.android in build.gradle

  • a gradle property with the name ANDROID_HOME: defined in ~/.gradle/gradle.properties or by passing -PANDROID_HOME to the gradle build

  • a system environment variable with the name ANDROID_HOME

The jfxmobile plugin will first try to look if an androidSdk property has been set. If not, it will look for the ANDROID_HOME gradle property and finally resort to the ANDROID_HOME system environment variable.

Community
  • 1
  • 1
jns
  • 6,017
  • 2
  • 23
  • 28
  • I verified that Gradle can find "$System.env.ANDROID_HOME" with a task that does println("$System.env.ANDROID_HOME"). The output was correct. – progonkpa May 14 '16 at 18:30
0

I installed IntelliJ 2016.1.2 Community edition and I can confirm that all dependencies loaded well including android.jar, jfxdvk.jar and the robovm jars. For some reason it failed with IntelliJ 15.0.6 ultimate.

progonkpa
  • 3,590
  • 9
  • 31
  • 50