- Tutorials
- Integrating the mimik Client Library into an Android project
Integrating the mimik Client Library into an Android project
Objective
The objective of this document is to demonstrate the various concepts iOS software developers need to understand to integrate the mimik Client Library with an Android application.
Intended Readers
The intended readers of this document are Android software developers and system integrators using the mimik Client Library when developing an Android application.
What You'll Be Doing
In this article you'll be covering the following topics that are relevant to integrating the mimik Client Library into an iOS application:
- Integrating the mimik Client Library using the Gradle Build Tool
- Initializing the mimik Client Library
Technical Prerequisites
This tutorial has the following technical prerequisites:
- A working Android Studio environment. You can download Android Studio here.
- An ARM-based Android device. The mim OE Runtime for Android does not support virtual or x86-based devices.
Adding the mimik Client Library for Android Dependency
The mimik Client Library for Android is a dependency that gets included as a Maven repository. The segments that follow show an example of the declarations that developers will include in their Android project. The project* and module-level build.gradle
files define the required Maven repository, and dependencies and configuration values for the library.
The project-level settings.gradle
file declares the repositories that will be used by the project, here specifying the location of the mimik Maven repository.
1: dependencyResolutionManagement {2: repositories {3: maven {4: url "https://s3-us-west-2.amazonaws.com/mimik-android-repo"5: }6: }7: }
The module-level build.gradle
file declares the dependency for the module.
1: dependencies {2: implementation 'com.mimik.mim-oe-sdk-android:mim-oe-client:3.13.1'3: }
Enable Cleartext Communication
mim OE hosts APIs on the local network interface. To allow this type of communication on Android devices, add the following property to the application in the module AndroidManifest.xml
.
1: <manifest>2: <application3: android:usesCleartextTraffic="true">4: </application>5: </manifest>
Initializing the mimik Client Library
In order to get the mimik Client Library up and running in an Android project, a developer needs to initialize it. Initialization involves importing a reference to MimOEClient
and then creating an instance variable using the constructor.
The code listed below shows an example of the code a developer writes to create an instance of the mimik Client Library. Notice the use of the MimOEClient(Context context, EdgeConfig edgeConfig)
constructor. The default MimOEConfig()
constructor automatically selects default parameters. This will have the mim OE Runtime host URLs using port 8083, and use the default license required to work with the mim OE Runtime.
1: MimOEClient mimOEClient =2: new MimOEClient(getContext(), new MimOEConfig());
You now have an initialized mimik Client Library in your Android application.
Ready
With that, the mimik Client Library has been initialized, its modules imported and its interface is ready to be used in your Android project.
Additional reading
In order to get more out of this article, the reader could further familiarize themselves with the following concepts and techniques: