This content has been archived.

Setting up the Mashup SDK for Android app development in Pega 7.2.1

This article describes how to set up the Mashup SDK in the Android Studio development environment so that its API can be used in the development of native Android apps.


The native Android app that uses the Mashup SDK must be developed using:

  • Java programming language
  • Android Studio or another IDE to create apps for Android 4.1 and later, 5.x, and 6.x

Make sure that you have already done the following tasks:

  • Read the Mashup SDK overview article
  • Have experience developing Android apps
  • Downloaded the Mashup Demo application that is distributed in the same package as the Mashup SDK

Add the Mashup SDK to Android Studio

Perform the following steps:

  1. Create a project or open an existing one in Android Studio or another IDE.
  2. In the android{} section of the application build.gradle file, add the following lines at the beginning of the file:

    apply plugin: 'base'
    apply plugin: 'extensionDetector'

  3. If the repositories{} section in the application build.gradle file does not already exist, create it with the entries shown below. Add the same entries to the buildscript{repositories{}} section of the project build.gradle file that is in the root folder of the Android Studio project. In both cases, do not forget to replace the <MASHUP_SDK_PATH> string with the path to where the extracted Mashup SDK for the Android distribution files are located.

    maven {
      url 'file:///<MASHUP_SDK_PATH>/repository/modules'
    ivy {
      url 'file:///<MASHUP_SDK_PATH>/repository/libraries'

  4. In the dependencies section in the buildscript{} section of the project build.gradle file, add the following lines:

    classpath ''
    classpath 'com.antennasoftware:commontools.extensiondetector:'
    classpath 'org.reflections:reflections:0.9.9.vol1'

  5. In the top level dependencies{} section of the application build.gradle file, add the following lines:

    compile 'com.squareup.dagger:dagger-compiler:1.2.2.vol1'
    compile 'com.pega:base:'
    compile 'com.pega:prpcAuthentication:'
    compile 'com.pega.prpcSnapStart:'

  6. Edit the AndroidManifest.xml file and in the <application> element add the following new attribute:

  7. Copy the file from the <MASHUP_SDK_PATH>/samples/mashup/src/main/assets folder to the assets folder for your application (./app/src/main/assets by default).

  8. In the Java code for your Android native app, create a class to allow injecting your activity into the Mashup SDK.
    Make sure to generate the import statements manually or by using your IDE. Doing this is necessary for the code to successfully compile.
    import com.squareup.dagger:Module;
    import com.squareup.dagger:Provides;

    import javax.inject.Singleton;

      addsTo = AppModule.class, library = true, injects = {
    public class AppModule {
      private final MainActivity activity;

      public AppModule( final MainActivity activity ) {
        this.activity = activity;

      MainActivity provideActivity() {
        return activity;

  9. In your MainActivity class, add the following annotated field:
    ContainerDelegate container;

  10. Append the following code to the onCreate() method right after the call to super.OnCreate():
    ContainerApplication.instance.addModule( new BaseActivityModule(this) );
    ContainerApplication.instance.addModule( new MainActivityModule(this) );
    ContainerApplication.instance.inject( this );
  11. Add the following callback delegates:

    protected void onDestroy() {
    public void onBackPressed() {
      if (!container.onBackPressed()) {
    public void onResume() {
    public void onPause() {
    public void onStop() {
    public void onStart() {
    public void onRestart() {
      public void onActivityResult( int requestCode, int resultCode, Intent data ) {
        super.onActivityResult( requestCode, resultCode, data );
        container.onActivityResult( requestCode, resultCode, data );

    The Mashup SDK is now set up in your project.

Verify that the Mashup SDK is correctly configured

To verify that the Mashup SDK is correctly configured in your project, create a HybridWebView component in your layout file, and then load a URL into it:

  1. Make sure that your layout file (for example, main_layout.xml), has the following contents:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android=""

  2. Append the following Java code to the end of the onCreate() method in the MainActivity Java object. Make sure to replace the following sample URL string with one that points to your Pega 7 Platform application instance.

    HybridWebView webview = (HybridWebView) findViewById(;

Related Content

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.