README.android

Overview
========

The FreeRDP Android port consists of three parts:
* Android Java GUI (client/Android/Studio)
* FreeRDP library and its dependencies
* JNI bindings (client/Android/android_freerdp.c
  and client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/LibFreeRDP.java)

Build requirements
=================

For the Android port some additional dependencies need to be fulfilled:

* for JNI
- CMake >= 3.0
- Android NDK (>= r9)

* for the Java GUI
- Android SDK

FreeRDP requires openssl libraries for building but they are not part of the
Android NDK and therefore they need to be prebuild manually.

For jpeg support https://github.com/akallabeth/jpeg8d has been tested and used.
However, any other static builds should work as well.

Build native libraries:
======================
From the project root run the build script
./scripts/android-build-freerdp.sh --ndk <ANDROID_NDK> --sdk <ANDROID_SDK>
Set ANDROID_NDK and ANDROID_SDK to the absolute paths on your machine.
This will fetch sources from git and build OpenSSL, OpenH264, libJPEG.
The native FreeRDP libraries will also be build.

Currently the default script builds for:
* armeabi
* armeabi-v7a
* x86
* mips
* arm64-v8a
* x86_64
* mips64

When the script is finished the libraries are ready for android studio to
be picked up in client/Android/Studio/freeRDPCore/src/main/jniLibs

The default configuration build configuration can be found in
./scripts/android-build.conf and is configured to provide debug builds.
They are limited to API level 21 and above.

If release binaries (and old android API support) are required, build 32 bit architectures with
./scripts/android-build-freerdp.sh --ndk <ANDROID_NDK> --sdk <ANDROID_SDK> --conf ./scripts/android-build-32.conf
and 64 bit architectures with
./scripts/android-build-freerdp.sh --ndk <ANDROID_NDK> --sdk <ANDROID_SDK> --conf ./scripts/android-build-32.conf

Building the APK (Android Studio)
================

* Import the folder client/Android/Studio in Android Studio
* You are ready to go

Building the APK (gradle)
================

* change to directory client/Android/Studio
* run ./gradlew build to build
* run ./gradlew tasks for other gradle options

Development
===========

Updating JNI
------------

Whenever the FreeRDP API changes or you need some extra functionality in your Java
GUI the JNI needs to be updated.

The JNI functions are defined in client/Android/android_freerdp.c
Add the new functions to the methods struct.

* edit client/Android/src/com/freerdp/afreerdp/services/LibFreeRDP.Java to
  reflect your changes
* edit client/Android/android_freerdp.c and adjust the methods struct to reflect
  the changes made.