SDK integration

Resolving StackOverflow Exception

Applications that override a base class set listener method may experience a StackOverflowException. The StackOverflowException is caused by the application inadvertently taking ownership of a listener the Medallia Experience Orchestration SDK is setting. To prevent the exception, the application must take care not to add the Medallia Experience Orchestration listener to those listeners managed by the application.

In the following example, an application developer has implemented the setOnPageChangeLister, intercepting all OnPageChangeListeners. The conditional statement is necessary to exclude all OnPageChangeListeners the Medallia Experience Orchestration SDK may set from being managed by the application.

Here an application developer has implemented the setOnPageChangeLister, excluding all Medallia Experience Orchestration SDK OnPageChangeListeners.

public final void setOnPageChangeListener(OnPageChangeListener listener) {
	if (listener.getClass().getName().contains("com.medallia")) {
            return;
        }
	listeners.add(listener);
}
Tip: Add the if statement only to those set listeners that interfere with the Medallia Experience SDK, causing the StackOverflowException.

Resolving conflicts with android:allowBackup

The Medallia Experience Orchestration SDK ships with allowBackup=true in the SDK's AndroidManifest.xml, which is the Android default setting. The Medallia experience Orchestration SDK sets allowBackup to ensure the tid in use is backed up in the event the end user application is built to allow backups. An application disabling backup does not affect the use of the Medallia Experience Orchestration SDK. Resetting the end user device followed by a restore, however, may generate a new user tid. To disable backup in an application, add the following to the applications AndroidManifest.xml

tools:replace="android:allowBackup"
android:allowBackup="false"

For more information about backing up user data, see Back up user data in the Android Developer's guide.

Resolving 'NoSuchMethodError' for Base64 class or 15000: Signpost cannot be used on this platform

This error can occur on some versions of the Android platform that include an outdated version of the org.apache.commons.codec.binary package. The platform version of the class is loaded onto the classpath before the bundled version of the class included in the APK. The outdated version of the class does not contain a method required by a third-party library which the Medallia Experience Orchestration SDK uses, Signpost, resulting in the error when attempting to access the missing method. You can see similar issues here and on StackOverflow.

We are investigating long term solutions for this atypical situation and suggest the Medallia Experience Orchestration SDK not be initialized if this method cannot be found. Below is a sample of how this can be achieved.

public class MyApplication extends Application {
	@Override
    	public void onCreate() {
        	try { 
          		Class base64Class = Base64.class;
          		base64Class.getMethod("encode", byte[].class);
          		// Init MXO SDK
        	} catch (NoSuchMethodException e) {
           		Log.e("MyApplication", "Base64 Encode Missing. Not initializing MXO SDK. " + e.getMessage());
        	}
    	}
}

Resolving AndroidX Version Conflicts

The Medallia Experience Orchestration SDK may bring in transitive AndroidX dependencies in order to support Interaction tracking which may not be desired. If an unwanted transitive dependency has been brought into an app, developers may exclude it. The Medallia Experience Orchestration SDK checks for transitive dependencies at Runtime in User mode to ensure no crashes occur by using an excluded dependency. The Medallia Experience Orchestration SDK does also use AndroidX dependencies in Admin mode for UI purposes but attempts to only use the lowest possible version. If developers find they need to exclude a transitive dependency due to an AndroidX bug in newer version, we recommend following the Gradle guidelines found here.

Example exclusion of AndroidX Fragments:

dependencies {
	implementation("com.medallia:mxo-android-sdk:{SDK_VERSION}") {
    		exclude(group = "androidx.fragment", module = "fragment")
  	}
}
dependencies {
	implementation "com.medallia:mxo-android-sdk:{SDK_VERSION}", {
    		exclude group: 'androidx.fragment', module: 'fragment'
  	}
}

Resolving 'namespace not specified' error

This error occurs after the Android Gradle Plugin is updated to version 8.x.x. The namespace has been removed from AndroidManifest.xml and transferred to the build.gradle(.kts) file. Even if your project's namespace is transferred to the new system, some plugins may not be updated to recent Gradle versions.

To eliminate the error use AGP Upgrade Assistant to upgrade Gradle version. To do that, if your project's Gradle version is 7.x.x, open it in Android Studio, and wait. When building the Gradle finish, you will see a popup in the bottom-right corner of the screen prompting you to start AGP Upgrade Assistant and process upgrading. After the upgrade, update your top-level build.gradle(.kts) file for adding the namespace its sub-projects (plugins) via Gradle as follows:
subprojects {
    afterEvaluate { project ->
        if (project.hasProperty('android')) {
            project.android {
                if (namespace == null) {
                    namespace project.group
                }
            }
        }
    }
}

After you have done that, rebuild your project. Note that you might need to invalidate caches and restart Android Studio.

Resolving 'java.lang.NoClassDefFoundError: com.medallia.mxo.internal.logging.LoggerSDK' error

The MXO SDK requires Kotlin 1.9+. Please ensure that you are on using Kotlin 1.9 or higher.