3

enter image description here

Above is my Gluon project to deploy JavaFX on Android. My problem is that I cant reference the android.jar. How to resolve this?

build.gradle

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

apply plugin: 'org.javafxports.jfxmobile'

repositories {
    jcenter()
}

mainClassName = 'com.raes.Main'

jfxmobile {
    android {
        manifest = 'src/android/AndroidManifest.xml'
    }
    ios {
        infoPList = file('src/ios/Default-Info.plist')
    }
}
Ethyl Casin
  • 791
  • 2
  • 16
  • 34
  • @José Pereda, Sir, do you have any idea of how to resolve this? – Ethyl Casin Jul 15 '15 at 07:03
  • 1
    Can you post your `build.gradle` file? I've got a Bluetooth working sample [here](https://bitbucket.org/JPereda/testbt), and I don't see that problem. – José Pereda Jul 15 '15 at 08:00
  • @JoséPereda, Sir please see build.gradle in the updated question. – Ethyl Casin Jul 15 '15 at 08:07
  • 1
    Are you including the android imports in your Source Packages [Java]? You need to add the code on the Android/Java Package! Check this sample [here](https://bitbucket.org/JPereda/testbt) to see how to reference the android code from the main one. – José Pereda Jul 15 '15 at 08:08
  • @JoséPereda, thank you very much! Its working now! – Ethyl Casin Jul 15 '15 at 08:21
  • Ok, I'll add it as a proper answer here – José Pereda Jul 15 '15 at 08:23
  • @JoséPereda, Sir, why cant I import the classes in android package to java package? – Ethyl Casin Jul 15 '15 at 08:34
  • 2
    @EthylCasin The reason is that the main sources are generic and not bound to any specific platform. This in term means that these sources will be included when building the appropriate packages for Android, iOS and desktop. If you would for instance include Android code inside the main sources, your code would only run on the Android platform. This kind of breaks the idea why javafxports was build in the first place: to build javafx applications on top of any platform. If you really need platform specific code, add it in the appropriate source directory. – Joeri Sykora Jul 15 '15 at 10:11

1 Answers1

6

When you create a JavaFX project using Gluon plugin for NetBeans, by default four main packages are created:

  • Source Packages [Java]
  • Desktop/Java Packages
  • Android/Java Packages
  • Ios/Java Packages

and four resources packages.

Also, if you check the Dependencies, by default there are exclusive dependencies for android (android.jar and jfxdvk jar) and for iOS (robovm jars).

Folders

This means that you can place Java code in any of the four given scopes, but you can use those dependencies only in their defined scope: you will be able to add android dependencies only under Android/Java Packages.

If you have a look at HelloPlatform under the samples repo of JavaFXPorts, you will see a way of dealing with how to call your platform specific code from the main application.

Also check this project, as it already includes Android Bluetooth dependencies, and see how they are called from the main class, by using a PlatformFactory class that loads on runtime the AndroidPlaftorm class if you are running your JavaFX app on an Android device.

José Pereda
  • 44,311
  • 7
  • 104
  • 132