Java Reference
In-Depth Information
4.
Use the JavaFX Dalvik SDK to create a JavaFX-Dalvik project. The JavaFX Dalvik SDK
contains a directory android-tools with a Gradle build script that requires some
parameters and that will produce the Android Application Project directory.
5.
Build the Android application. The Android Application Project directory contains an ant
structure that allows us to build the Android application.
6.
Install the application on an Android device, run it in an emulator, or submit it to the
Play store.
We demonstrate these steps next, again using the SimplePort application we introduced in the previous section.
Building JavaFX Android applications is a bit different from building JavaFX iOS applications. However, the same
source tree and even the same pom.xml file can be used as the starting point for both target environments. Because it
is at this time not possible to use Java 8 APIs (e.g., Stream API) on top of Dalvik, we need to tell the Java compiler that
we want to generate bytecode compatible with Java 7. The following additions to the pom.xml file will do this:
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
The first step in the JavaFX Android build sequence is similar to building regular JavaFX desktop applications.
You just create an application with JavaFX and Java code. As opposed to the RoboVM approach for generating iOS
applications, no launcher class is created in the source code of the application. However, because meta-information
is also required for creating Android applications, this implies that we need an additional step in the Android build
sequence that is not needed in the iOS build sequence.
The result of
mvn clean install
is a target directory containing
simpleport-1.0-SNAPSHOT.jar
In Step 4 of the sequence, we have to create a JavaFX Dalvik project using the Gradle build script provided
with the javafx-dalvik SDK. The android-tools directory in the javafx-dalvik SDK contains a build.gradle file that
requires a number of parameters. Typically, a build script is created that sets these parameters.
The following build script will create the SimplePort Android project, based on the JavaFX application we created
in the previous step.
#!/bin/bash
# this is an example script. Change the parameters according to your local setup
export ANDROID_SDK=/opt/android-sdk
export PATH=$ANDROID_SDK/tools:$PATH
export CURRENT_DIR=`pwd`
 
Search WWH ::




Custom Search