...
You will need to add our repository to the plugin repositories, as of time of writing, Cordova doesn’t support editing settings.gradle
, so you need to declare it in an init.gradle
file in $GRADLE_HOME
or passing the init file via cli cordova build android -- --gradleArg="--init-script init.gradle"
:
Code Block | ||
---|---|---|
| ||
settingsEvaluated { settings -> settings.pluginManagement { repositories { mavenCentral() gradlePluginPortal() google() maven { credentials { //Leave the username as "MAVEN" username "MAVEN" password "INSERT_YOUR_KEY" } url "https://mobile-protect-repos.securetheorem.com/mobileprotect-android" } } } } |
...
Code Block | ||
---|---|---|
| ||
allprojects { repositories { mavenCentral() google() // Mobile Protect Maven Repository maven { credentials { // Leave the username as "MAVEN" username "MAVEN" password "INSERT_YOUR_KEY" } url "https://mobile-protect-repos.securetheorem.com/mobileprotect-android" } } } |
If you use Cordova Cordova’s default repositories.gradle
setup, you will need to add our repository to all repositories.gradle
files. There are usually three of these:
platforms/android/repositories.gradle
platforms/android/app/repositories.gradle
platforms/android/cordovaLib/repositories.gradle
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" } } |
...
Code Block | ||
---|---|---|
| ||
MobileProtect.init(this, R.xml.mobileprotect); |
If you don’t have an Application
object, you need to create one and register it in AndroidManifest.xml
5. Optional: configuration for static obfuscation
You can enable Mobile Protect obfuscation in the project build.gradle with:
Code Block |
---|
MobileProtectPluginConfiguration {
enableObfuscation = true
} |
If static obfuscation is enabled for a Cordova project then the following proguard rules must be added to your proguard-rules.pro
file in order to prevent plugins from breaking:
Code Block |
---|
-dontwarn kotlin.reflect.jvm.KCallablesJvm
-keep class org.apache.cordova.** {*;}
-keep class * extends org.apache.cordova.CordovaPlugin {*;} |
If your project does not contain a proguard-rules.pro
file you can add one in platforms/android/app/build.gradle
Code Block |
---|
android {
//...
buildTypes {
release {
//...
proguardFiles("proguard-rules.pro")
}
}
} |
...
Other Installation Guides
...