Android SDK Integration
Before you startMake sure you've obtained a token, server URL, and auth key from credolab Customer Success Manager.
The minimal supported Android version is 5.0 Lollipop. Programming language Kotlin or Java.
1. Add a repository
Open gradle.properties file, then add token provided by your CSM:
credolabToken=YOUR_ACTUAL_TOKEN_HEREMake sure
gradle.propertiesfile is added to.gitignoreof your Android project.
In the project build.gradle or settings.gradle file, add:
repositories {
..
maven {
url "https://dl.cloudsmith.io/${credolabToken}/credolab/proxyen-sdk/maven/"
}
}repositories {
..
maven {
url = uri("https://dl.cloudsmith.io/${credolabToken}/credolab/proxyen-sdk/maven/")
}
}dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
..
maven {
url "https://dl.cloudsmith.io/${credolabToken}/credolab/proxyen-sdk/maven/"
}
}
}dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
..
maven {
url = uri("https://dl.cloudsmith.io/${credolabToken}/credolab/proxyen-sdk/maven/")
}
}
}Keep secrets out of VCS
Never embed your secrets directly in
build.gradleorsettings.gradle. These files are typically committed to version control, exposing sensitive credentials.Store
gradle.propertieslocally and rely on environment variables in CI/CD.
2. Declare dependencies
In the app build.gradle or build.gradle.kts file, add the following
dependencies {
// Required for core module
implementation 'com.google.code.gson:gson:2.8.5'
// Core module
implementation 'com.credolab:modular.core:X.Y.Z'
// Modules: each module is optional
implementation 'com.credolab:modular.account:X.Y.Z'
implementation 'com.credolab:modular.calendar:X.Y.Z'
implementation 'com.credolab:modular.contact:X.Y.Z'
implementation 'com.credolab:modular.audio:X.Y.Z'
implementation 'com.credolab:modular.images:X.Y.Z'
implementation 'com.credolab:modular.video:X.Y.Z'
implementation 'com.credolab:modular.guard:X.Y.Z'
implementation 'com.credolab:modular.behavioral:X.Y.Z'
implementation 'com.credolab:modular.behavioral-phone:X.Y.Z'
implementation 'com.credolab:modular.behavioral-guard:X.Y.Z'
// If your project is on Java
implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.3.0' * — for Java project
// Optional: if you want to use logging module
implementation 'com.credolab:modular.logging:X.Y.Z'
implementation 'io.sentry:sentry-android:8.14.0'
}dependencies {
// Required for core module
implementation("com.google.code.gson:gson:2.8.5")
// Core module
implementation("com.credolab:modular.core:X.Y.Z")
// Modules: each module is optional
implementation("com.credolab:modular.account:X.Y.Z")
implementation("com.credolab:modular.calendar:X.Y.Z")
implementation("com.credolab:modular.contact:X.Y.Z")
implementation("com.credolab:modular.audio:X.Y.Z")
implementation("com.credolab:modular.images:X.Y.Z")
implementation("com.credolab:modular.video:X.Y.Z")
implementation ("com.credolab:modular.guard:X.Y.Z")
implementation("com.credolab:modular.behavioral:X.Y.Z")
implementation("com.credolab:modular.behavioral-phone:X.Y.Z")
implementation("com.credolab:modular.behavioral-guard:X.Y.Z")
// Optional: if you want to use logging module
implementation("com.credolab:modular.logging:X.Y.Z")
implementation("io.sentry:sentry-android:6.3.1")
}
NotePlease replace
X.Y.Zwith module versions from Android page. The final result should look like this:implementation 'com.credolab:example:4.0.0'implementation("com.credolab:example:4.0.0")
Using [includeInBundle: Boolean]
truevalue in the application-levelbuild.gradlefile includes dependency information in your Bundle, as recommended by Google. Default value istrueif thedependenciesInfosection is not declaredandroid { ... dependenciesInfo{ includeInBundle = true } }
2.1 Add imports
Copy and paste import statements if needed. Delete imports for unused modules or plugins.
import credoapp.CredoAppResult
import credoapp.CredoAppService
import credoapp.module.account.RegisterAccountModule
import credoapp.module.audio.AudioModule
import credoapp.module.behavioral.BehavioralModule
import credoapp.module.calendar.CalendarModule
import credoapp.module.calllog.CallLogModule
import credoapp.module.contact.ContactModule
import credoapp.module.images.ImagesModule
import credoapp.module.iovation.FraudForceModule
import credoapp.module.mlimages.MLImagesModule
import credoapp.module.smsintelligence.SecurityParam
import credoapp.module.smsintelligence.SmsIntelligenceModule
import credoapp.module.guard.GuardModule
import credoapp.module.telephony.TelephonyModule
import credoapp.module.video.VideoModule
import credoapp.plugin.behavioral.phone.PhoneBehavioralPlugin
import credoapp.plugin.behavioral.guard.GuardBehavioralPlugin
import credoapp.plugin.logging.LoggingPlugin3. Modify AndroidManifest
Click on the recipe to see what you need to add to your manifest file.
Play Feature DeliveryIf you use Play Feature Delivery in your project, to avoid runtime errors please add this code to your
<application/>tag of AndroidManifest file:<application ...> <provider android:authorities="${applicationId}.credoapp.core" android:name="credoapp.CoreProvider" tools:node="remove" /> </application>For Behavioral Module please refer to Using Behavioral Module with Dynamic Feature
Also, whenever minSdkVersion is lower than 21 API, please wrap SDK calls with version check:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
credoAppService = CredoAppService.Builder(applicationContext)
}4. Build and use CredoAppService
Add this code to the onCreate method in your MainActivity.kt file
// When using the BehavioralModule, you can invoke the startTracking method at any point,
// even before the SDK is initialized. Call this method at the beginning of a certain user flow
BehavioralModule.startTracking()
val credoAppService = CredoAppService.Builder(applicationContext)
.addModule(AudioModule())
.addModule(BehavioralModule())
.addModule(CalendarModule())
.addModule(ContactModule())
.addModule(ImagesModule())
.addModule(RegisterAccountModule())
.addModule(VideoModule())
.addModule(GuardModule()
.addPlugin(LoggingPlugin())
.build()
// Stop the behavioral tracking to conserve resources or mark the end of a user flow
BehavioralModule.stopTracking()// When using the BehavioralModule, you can invoke the startTracking method at any point,
// even before the SDK is initialized. Call this method at the beginning of a certain user flow
BehavioralModule.startTracking();
CredoAppService credoAppService = new CredoAppService.Builder(applicationContext)
.addModule(new AudioModule())
.addModule(new BehavioralModule())
.addModule(new CalendarModule())
.addModule(new ContactModule())
.addModule(new ImagesModule())
.addModule(new RegisterAccountModule())
.addModule(new VideoModule())
.addModule(new GuardModule()
.addPlugin(new LoggingPlugin())
.build();
// Stop the behavioral tracking to conserve resources or mark the end of a user flow
BehavioralModule.stopTracking();
Additional steps for Behavioral ModulePlease refer to
BehavioralModulesection for additional information about integration.
Now, you're able to use the service
val result = credoAppService.collect()
when (result) {
is CredoAppResult.Success -> Log.d(TAG, result.value)
is CredoAppResult.Error -> Log.d(TAG, "${result.message} ${result.code}")
}CredoAppResult<String> result = credoAppService.collect();
if (result instance of CredoAppResult.Success) {
Log.d(TAG, ((CredoAppResult.Success<String>) result).getValue());
} else {
CredoAppResult.Error error = (CredoAppResult.Error) result;
String errorMessage = (error.getMessage() + " " + error.getCode());
Log.d(TAG, errorMessage);
}
NoteRemember that you always must call
collectmethod on a background thread.If
collectis successful, it will return the dataset value.
Behavioral data is cleared oncollect()method callOnce
collect()method is calledBehavioralModuleclears its data stored on user the device.Thus, for data consistency, our strong recommendation is to call the method only once: at the end of the user flow.
4. Upload from an Android Device (Testing purposes only)
Direct Upload NoteIn a production environment, datasets should only be uploaded via your organization's proxy server.
For testing, integration, or generating insights, you may use the following code snippet:
If you have any further questions, please do not hesitate to contact us.
Video Tutorials
Core Module Integration Tutorial
Optional Modules Integration Tutorial
Behavioral Module Integration Tutorial
Next Steps
After successfully integrating our SDK, it is recommended to proceed with the following steps to utilise our platform effectively:
- Setting up your Reverse Proxy
- Uploading your Dataset. Once the server is configured, you can upload your dataset using the server address.
- Collecting your Dataset Insight or TruValidate(formerly known as iovation) Fraud Check. With the dataset uploaded, you can now get insights or perform TruValidate Fraud Checks to assess risk based on the device and transaction details provided.
Updated 21 days ago
