Java facade integration
The following steps explain how to integrated the TPSDK facade into an Android Studio Project. Note that the following steps are meant to guide the developer - as always there are multiple ways to reach the goal.
Create a new Project
Create a new project in Android Studio.
After everything is set up, click on File
and New
, then select Import Module
.
In the following file chooser navigate to the CatalystFacadeX
folder as part of the zip file shipping with the SDK.
Import the CatalystFacadeX
module so it becomes a part of your project.
Copy/ paste libraries and native files
TPSDK uses different technologies to create outputs like Java and C#. A core part of this stack are native libraries - which need to get copied manually.
There are multiple ways to import native files in Android studio.
As of today the easiest structure looks like this - with the given structure Android Studio/ Gradle detect the native files directly and the gradle files don’t need modifications:
.
├── app.iml
├── build
├── build.gradle
├── libs // Directory to put your jar/ aar libs
├── proguard-rules.pro
└── src
└── main // The main application
├── AndroidManifest.xml
├── java
├── jniLibs // Directory to put your jni libs, i.e. the .so files.
└── res
Here
- all
so
files get copied into the jniLibs folder and - all
aar
to the libs folder
Adjust gradle files (project and main app)
As of now a make project
command would fail miserably as the facade
is not made known to the app.
To finally build the project the build.gradle
file of the main module (something like main.app) needs a dependency to the facade as well as the native libs in case the structure is different from the above example
dependencies {
implementation fileTree(include: ['*.aar'], dir: 'libs')
implementation project(path: ':CatalystFacadeX')
api files('../trimble/empowerlib-1.2.0.26.aar')
api files('../trimble/Trimble.Licensing.Android.aar')
api files('../trimble/trimble.jssi.core-release.aar')
api files('../trimble/trimble.jssi.android.communicators-release.aar')
api files('../trimble/JTDDTransformation-release.aar')
}
Its also required to tell java where the native files are located. Hence the android
section of the gradle file needs also an extension
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
Finally a gradle sync
and make project
are required to finish the integration.
The project should build without complaints.
Using the facade
We can now initialize the facade via something like
CatalystFacade facade = new CatalystFacade(myAppGUID, this);
where myAppGUID
is either the GUID from the facade sample or the received GUID from Trimble.
Note that the manifest permissions need some adjustment before deploying the application. For details on manifest permission please check the documentation.