A lightweight Kotlin wrapper around Zebra's EMDK for Android that takes the boilerplate out of initialising the EMDK Manager and processing MX profiles — including proper parsing of the XML response so you actually find out when a profile fails.
EMDK is hosted in Zebra's Artifactory, so add that repository alongside Maven Central in your settings.gradle:
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven { url = "https://zebratech.jfrog.io/artifactory/EMDK-Android/" }
}
}Then add the dependency (the EMDK dependency is pulled in transitively):
dependencies {
implementation 'dev.nilac:emdk-loader:2.0.0'
}EMDKLoader.getInstance().initEMDKManager(context, object : EMDKManagerInitCallBack {
override fun onSuccess() {
// Ready to process profiles
}
override fun onFailed(message: String) {
Log.e(TAG, "EMDK init failed: $message")
}
})Every variant takes the same ProfileLoaderResultCallback:
val callBacks = object : ProfileLoaderResultCallback {
override fun onProfileLoaded() {
Log.i(TAG, "Profile applied")
}
override fun onProfileLoadFailed(message: String, errors: List<ProfileError>) {
Log.e(TAG, "Profile failed: $message")
// `errors` holds the structured <parm-error> / <characteristic-error>
// entries parsed from the MX response, when available.
}
}1. Apply a profile bundled in your assets — pass null as the profile data and the named profile (from assets/) is processed as-is:
ProfileLoader().processProfile("MyProfile", null, callBacks)2. Apply an inline / dynamic profile — pass an XML string as the profile data, useful when values are only known at runtime (package name, signature, etc.):
val profileXml = """
<wap-provisioningdoc>
...
</wap-provisioningdoc>
""".trimIndent()
ProfileLoader().processProfile("MyProfile", profileXml, callBacks)3. Apply after a delay — same as above but waits delayMillis before processing (handy when a profile must settle after another change):
ProfileLoader().processProfileWithDelay("MyProfile", profileXml, 2000L, callBacks)
processProfile(...)andprocessProfileNow(...)both apply the profile as soon as the Profile Manager is ready.
Because the response is parsed, a CHECK_XML result that hides a <parm-error> or <characteristic-error> is reported through onProfileLoadFailed as a real failure — not a false success.
EMDKLoader.getInstance().release()2.0.0 moved to Maven Central and includes breaking changes. If you were consuming the library through JitPack:
-
Dependency & repository — drop the
jitpack.iorepository and swap the coordinate:- implementation 'com.github.nilac8991:emdk-loader-lib:1.1.1' + implementation 'dev.nilac:emdk-loader:2.0.0'
-
Package rename — update your imports from
com.zebra.nilac.emdkloadertocom.nilac.emdkloader. -
Callback change —
ProfileLoaderResultCallbacknow has a single failure method (theEMDKResultsoverload was removed):- override fun onProfileLoadFailed(message: String) { } - override fun onProfileLoadFailed(errorObject: EMDKResults) { } + override fun onProfileLoadFailed(message: String, errors: List<ProfileError>) { }
The library only wraps the EMDK — it does not replace it. For how the EMDK and MX profiles actually work, please refer to Zebra's official Documentation on TechDocs.
Licensed under the Apache License 2.0.