Overview

HTTPS SSH
IMPORTANT:
This project has been moved to https://bitbucket.org/javafxports/android

Build instructions are there, and binary downloads are available as well there.

This page won't be updated.
========================================================================

This project provides code and build instructions for running JavaFX 
applications on the Android platform.

There is not much new code in this project, but we try to bring together
all involved code and steps needed to perform to get JavaFX applications
running on Android devices.

We're looking for a better name instead of johanvos/jfx78 -- suggestions
are very welcome.

But for now, here we go with the instructions:

1. Install the Android SDK and the Android NDK
Download the Android SDK here: http://developer.android.com/sdk/index.html
Download the Android NDK here: http://developer.android.com/tools/sdk/ndk/index.html

The instructions here assume you install the SDK in /opt/android-sdk-linux and
the NDK in /opt/android-ndk-r9b

2. Building freetype libraries

You need to have a cross-compiled build for Android. Here are the steps to do this:
2.1. Download freetype
2.2. Create a toolchain for cross-compiling the sources
2.3. Compile

2.1. Downloading freetype
Download the freetype sources from http://download.savannah.gnu.org/releases/freetype/freetype-2.5.0.tar.bz2

2.2. Create a toolchain
export ANDROID_SDK=/opt/android-sdk-linux
export ANDROID_NDK=/opt/android-ndk-r9b
export JAVA_HOME=/opt/jdk1.7.0
mkdir toolchain
$ANDROID_NDK/build/tools/make-standalone-toolchain.sh  --platform=android-19 --install-dir=toolchain

2.3. Compile
cd into the freetype sources
export TOOLCHAIN=/path/to/toolchain
export PATH=$TOOLCHAIN/bin:$PATH
export FREETYPE=`pwd`
./configure --host=arm-linux-androideabi --prefix=$FREETYPE/install --without-png --without-zlib --enable-shared
sed -i 's/\-version\-info \$(version_info)/-avoid-version/' builds/unix/unix-cc.mk
# if you are on a mac use the following line instead of the one above
#sed -i '.orig' 's/\-version\-info \$(version_info)/-avoid-version/' builds/unix/unix-cc.mk
make
make install

3. Build the JFX78
In this step, you need the sources contained in this bitbucket project. When you cloned the project,
you can execute the run.sh script, which will do the following:

JAVA_HOME=/opt/jdk1.7.0
JDK_HOME=/opt/jdk1.7.0
gradle -PANDROID_SDK=/opt/android-sdk-linux -PANDROID_NDK=/opt/android-ndk-r9b -PDEBUG -PDALVIK_VM=true -PBINARY_STUB=/opt/jdk1.8.0/jre/lib/jfxrt.jar \
-PFREETYPE_DIR=/home/johan/android/fox/freetype/src/freetype-2.4.0/install -PCOMPILE_TARGETS=android

3. Create a standalone JavaFX Project
Use Netbeans or your favourite  IDE to create a standalone HelloWorld java project. Use Java7 to compile the project.
You will need the location of the output directory (containing the jar) in the next step (it will be called JFX_APP).

4. Create the Android Project based on your project and on the the jfx78 build:

You don't have to create any new sources. The only thing that happens here
is the creation of an environment that allows you to build the .apk.
In the android-tools directory created in the previous step is a gradle script.

You have to supply a few parameters:

NAME is a name of Android project.
DIR is the output directory, the .apk will be in this place
PACKAGE is package name required by Android. It has nothing to do with a packaging of javafx application, but you can use the same name
JFX_SDK points to the built runtime created in the previous step
JFX_APP points to dist directory of your javafx application. (where all application jars sit)
JFX_MAIN is fully qualified name of a main class, the starting class for your JavaFX Application

Execute the gradle script with the specified parameters:

gradle -PDEBUG -PDIR=/home/user/work -PNAME=HelloWorld -PPACKAGE=com.helloworld \
-PJFX_SDK=/home/user/work/jfx78/build/android-sdk -PJFX_APP=/home/user/NetBeansProjects/HelloWorld/dist \
-PJFX_MAIN=com.helloworld.HelloWorld createProject

5. Create the apk
cd into the new project and type
ant debug

6. Run it
Connect your Android phone to your system using USB. Enable developer tools
on the phone, and allow debugging over USB
upload the apk:
$ANDROID_SDK/platform-tools/adb install -r /path/to/the/app-debug.apk

Look into applications on your phone, and start the app.