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)
* More documentation might be found at https://github.com/FreeRDP/FreeRDP/wiki/Compilation

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

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

* for JNI
- CMake >= 3.13 (install CMake from Android SDK. It is part of the SDK Tools)
- Android NDK (>= r15c)

* 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.

* [optional] cJSON is required for logging in to Azure accounts
* [optional] Kerberos authentication is supported by MIT or Heimdal kerberos libraries
* [optional] 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-v7a
* x86
* arm64-v8a
* x86_64

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-64.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.

