Installation
You can install Cello for Android using Gradle or manually. A basic installation takes around 15 minutes but will take a little longer if you want to customize the way the Cello Referral Component is launched.Compatibility
Cello SDK for Android is compatible with API 21 and up.SDK size
The size of Cello for Android once installed varies depending on your app’s configuration. Around 7MB is the average size increase we would expect to see if you’re minifying your app correctly.Setup
Install Cello to see and give your users the option to spread the word from your Android app. Cello for Android supports API 21 and above. Note: We recommend using the latest availablecompileSdkVersion.
Install Cello
Add the following dependency to your app’sbuild.gradle file:
Groovy (or Kotlin DSL)
build.gradle:
Choose an Environment
In your Cello SDK setup, you have the flexibility to select the environment in which your application will run. This feature is especially useful for different stages of development, such as testing in a development or staging environment before going live in production. The available environments are:prod(Production) – defaultsandbox(Sandbox)
Configuration Steps
In your Android project, open or createres/values/config.xml, then add:
cello_env. For instance, to set the environment to sandbox:
Initialize Cello
In this step, you will need your product ID and a token you have generated for the user, similar when implementing the web based Referral component. Then, initialize Cello by calling the following in theonCreate() method of your application class:
Note: If you don’t currently implement a custom application, you’ll need to create one. A custom application looks like this:
Kotlin
Java
Note: Cello SDK must be initialized inside the application onCreate() method. Initializing anywhere else will result in the SDK not behaving as expected and could even result in the host app crashing.
Customize the Cello Referral Component
The Cello SDK allows for various levels of customization to better fit into your app’s design and flow. One of the main components you might want to customize is the Referral component You have two options to launch the referral component:Default Launcher
If you choose to go with the default launcher, you can call theshowFab() method from the Cello SDK to present a Floating Action Button (FAB) within your app. This FAB is pre-styled but may not perfectly match your app’s look and feel.
Custom Launcher
If the default launcher does not fit your needs, you can implement your own custom launcher. This could be any UI element like a button, menu item, or even a gesture. To open the Referral component using a custom launcher, you can callCello.openWidget().
Android API
Cello.initialize()
Initializes the Cello referral component.
| Name | Type | Description | Required |
|---|---|---|---|
| activity | Activity | This is the reference to the MainActivity | Yes |
| productId | String | Identifier of the product your users will refer | Yes |
| token | String | Access token generated for the given user | Yes |
| productUserDetails | ProductUserDetails | Product user details | No |
| language | String | Initial language of the widget | No |
Cello.showFab()
Shows the Floating action button or bookmark that launches the Referral Component
Cello.hideFab()
Hides the Floating action button or bookmark that launches the Referral Component
Cello.openWidget()
Opens the referral component.
Cello.hideWidget()
Hides the referral component.
Cello.getActiveUcc()
A method to get an active ucc and invite link for the currently logged in user.
getCampaignConfig()
Returns campaign config values for the currently logged-in user.
Returns
The campaign config object:
Cello.changeLanguage()
A method to change the language of the Referral component at runtime without re-initialising it.
Cello.shutdown()
Shuts down connection to Cello and unmounts the component
Error Handling
Common Error Scenarios
1. Invalid Parameters
What it means: The product ID or token provided during initialization is empty or blank. Error behavior:- SDK initialization is silently skipped
- Warning logged:
"Initialization skipped: productId and token must not be empty or blank" - No exception thrown
- Empty strings for productId or token
- Whitespace-only strings
2. Network/API Errors
What it means: The network request to initialize the SDK or update token failed. Error type:RuntimeException("Response not successful")
Common causes:
- No internet connection
- Server errors (5xx responses)
- HTTP errors (4xx responses)
- Timeout issues
- Firewall or proxy blocking requests
3. Activity State Errors
What it means: The Activity is destroyed, finishing, or not available when trying to perform UI operations. Error type:IllegalStateException("Activity is not valid")
Error message: "Cannot perform UI operation - Activity is not available or destroyed"
Common causes:
- Calling SDK methods after Activity is destroyed
- Activity finishing during async operations
- Attempting UI operations during Activity transitions
4. Initialization Failures
What it means: The SDK failed to initialize due to an error in the initialization process. Error behavior:- Exception passed to callback
- Error logged:
"Error initializing widget: {exception message}" - Pending operations cleared
- Network connectivity issues
- Invalid credentials (product ID or token)
- Server-side configuration issues
Error Handling Best Practices
1. Always handle both success and error cases:Getting Help
If you encounter an error you can’t resolve:- Check the error scenario in the reference above
- Verify your integration follows the code examples
- Check logcat for detailed error messages:
adb logcat | grep cello-sdk - Verify network connectivity and firewall settings
- Ensure product ID and token are valid and not empty
- Check Activity lifecycle (not finishing or destroyed)
- Contact Cello support with:
- Full error message and stack trace from logcat
- Steps to reproduce
- SDK version
- Android OS version and device model
- Network conditions when error occurred