This repository contains the files of the Sternum Android SDK, a versatile and flexible tool for implementing Relay applications and adding observability and traceability into Android devices using Java and C/C++.
For introduction and integration information, refer to the Online documentation.
How to import the SDK
- Add the
sternum-sdk-[release/debug].aar
file under the app/libs
directory in the target's project.
- Add a dependencies in target's
build.gradle
file:
- Including release:
dependencies {
implementation files('libs/sternum-sdk-release.aar')
}
- Debug/release specific configuration:
dependencies {
debugImplementation files('libs/sternum-sdk-debug.aar')
releaseImplementation files('libs/sternum-sdk-release.aar')
}
For more information refer to https://stackoverflow.com/questions/16682847/how-to-manually-include-external-aar-package-using-gradle-for-android.
Using the API
The Sternum Android SDK offers two interfaces: Java API (com.sternum.cloud.SternumSDK) and the native API (sternum_sdk.h).
- To use the component within your code, add the following import:
import com.sternum.cloud.SternumSDK;
import com.sternum.cloud.protocol.tracing.Argument;
// Trace definition file which is obtained from Studio or the Sternum Platform.
// The package/path is specific to your project.
import com.example.example.TraceEventType;
// Argument definition file which is obtained from Studio or the Sternum Platform.
// The package/path is specific to your project.
import com.example.example.ArgumentRoleType;
Initialize the SDK:
The SDK can only be initialized from the Java API.
If you plan to use the SDK native API (with or without the Java API), link your native component with sternum_sdk_static.a
. Note that sternum_sdk_static.a
implements JNI_OnLoad
. If you encounter linking issues, please reach out to Sternum support.
Then, invoke the initialization routine with loadNative=false
(last parameter of the SternumSDK.initialize()
method as follows:
SternumSDK sternumSDK = SternumSDK.getInstance();
sternumSDK.initialize(getApplicationContext(), "gateway.sternum.cloud",
true, new BigInteger("1234123412341234"),
SternumSDK.DeploymentPhase.PRODUCTION, 0x2000, false);
- If you plan to use only the Java API, invoke the initialization routine as follows:
SternumSDK sternumSDK = SternumSDK.getInstance();
sternumSDK.initialize(getApplicationContext(), "gateway.sternum.cloud",
true, new BigInteger("1234123412341234"),
SternumSDK.DeploymentPhase.PRODUCTION, 0x2000, true);
- Sending traces:
sternumSDK = SternumSDK.getInstance();
sternumSDK.trace(TraceEventType.TRACE_OS_INFORMATION,
new Argument(ArgumentRoleType.ARG_ROLE_NAME, "Android"),
new Argument(ArgumentRoleType.ARG_ROLE_VERSION, Build.VERSION.SDK_INT));
- Relaying device data:
sternumSDK = SternumSDK.getInstance();
sternumSDK.relayDeviceData(SternumSDK.DeviceType.DEVICE_TYPE_A, deviceReceivedData);