...
Android: Add Mobile Protect SDK
1
...
. Add the Mobile Protect Maven Repository
The Mobile Protect for Android SDK is hosted on a private Maven repository. To be able to fetch the dependency, you must first register the dependency within your Gradle manifest.
You will need to add our repository to the plugin repositories, and , as of time of writing, Cordova doesn’t support editing settings.gradle
, you need to declare it in your settingsan init.gradle
file in $GRADLE_HOME
:
Code Block | ||
---|---|---|
| ||
pluginManagementsettingsEvaluated { settings -> repositoriessettings.pluginManagement { mavenCentral()repositories { gradlePluginPortalmavenCentral() google gradlePluginPortal() google() // Mobile Protect Maven Repository maven { maven { credentials { // Leave the username as "MAVEN" username "MAVEN" password "$MOBILEPROTECTINSERT_REPOYOUR_API_KEY" } url "<httpshttps://mobile-protect-repos.securetheorem.com/mobileprotect-android>android" } } } } |
Our plugin will then download its project dependencies so you will also need to add our repository to your project’s build.gradle
file:
Code Block | ||
---|---|---|
| ||
allprojects { repositories { mavenCentral() google() // Mobile Protect Maven Repository maven { credentials { // Leave the username as "MAVEN" username "MAVEN" password "$MOBILEPROTECTINSERT_REPOYOUR_API_KEY" } url "https://mobile-protect-repos.securetheorem.com/mobileprotect-android" } } } |
If you use Cordova default repositories.gradle
setup, you will need to add our repository to all repositories.gradle
files:
Code Block |
---|
ext.repos = { google() mavenCentral() maven { credentials { //Leave the username as "MAVEN" username "MAVEN" password "INSERT_YOUR_KEY" } url "https://mobile-protect-repos.securetheorem.com/mobileprotect-android" } } |
Note: If you use settings for dependency management (for ex. if you see the error “Build was configured to prefer settings repositories over project repositories”) the Data Theorem repository will need to be added in settings.gradle
under dependencyResolutionManagement->repositories
.
...
Note: If you encounter duplication issues because you have both TrustKit and MobileProtect, you can use the com.dtplugin.mobileprotect-notrustkit artefact and keep TrustKit as is.
3
...
.
...
Code Block | ||
---|---|---|
| ||
MobileProtect.init(this, R.xml.mobileprotect); |
Android: Mobile Protect Configuration
Add the Mobile Protect Config
In the Android project, create the xml
directory (/app/src/main/res/xml
) if it does not exist. Then, copy the mobileprotect.xml
config file into the xml
resources folder. mobileprotect.xml
can be downloaded from our portal.
The AUTH_TOKEN
key contained in the configuration file is not sensitive. The key is only used to identify the data sent by Mobile Protect to the backend, but cannot be used to pull any data from the app nor the backend. It is safe to commit and have the token in the .apk
as it is used as an identifier, similar to Google's Firebase: https://firebase.google.com/docs/projects/api-keys .
4. Initialize Mobile Protect
Now you're ready to initialize the SDK. Within your application's main Application
class, preferably in the onCreate()
method, add the following code:
Code Block | ||
---|---|---|
| ||
MobileProtect.init(this, R.xml.mobileprotect); |
...
Other Installation Guides
...