All Products
Search
Document Center

Mobile Platform as a Service:Integrate into Android

Last Updated:Feb 02, 2026

This topic describes how to preview cards on a real device in an Android client.

Prerequisites

  • You have enabled and integrated mPaaS.

  • You have installed the AntCubeTool. For more information, see About AntCubeTool.

  • You have completed the integration process as described in Getting Started.

Procedure

  1. Add the real-time preview dependency.

    1. Add the Cube Card-Developer Tool component.

    2. Add the third-party dependencies to the build.gradle file of the main project module. If a dependency conflict occurs, use your existing dependency versions.

      dependencies {
          ······
          implementation "com.squareup.okhttp3:logging-interceptor:3.12.12"
          implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.72'
          implementation "com.squareup.okhttp3:okhttp:3.12.12"
          implementation 'com.squareup.picasso:picasso:2.5.2'
          implementation 'org.simple:androideventbus:1.0.5'
          ·······
      }
  2. Run the following command in your project's directory to start the local debugging service:

    • macOS: act prepare && act server

    • Windows: act prepare | act server

      After you run the command, a QR code is generated in the terminal.

  3. Start the client and scan the QR code to connect.

    CubeCardDebug.openScanner(activity); 

    Because an internal network connection is established, if the targetVersion is greater than 27, you need to downgrade it or add a configuration in the manifest.

    android:usesCleartextTraffic="true" android:networkSecurityConfig="@xml/network_security_config" and the corresponding network_security_config.xml.

    <?xml version="1.0" encoding="utf-8"?>
    <network-security-config>
        <domain-config cleartextTrafficPermitted="true">
            <domain includeSubdomains="true">${your_local_IP_address}</domain>
        </domain-config>
    </network-security-config>

    After you scan the QR code, a toast notification appears on the client: Cube Socket: Connected.

    The terminal also shows that the device is connected.

  4. Preview

    Modify the card's code and run act build to compile it. Then, run act preview to push the compiled content to the client.