All Products
Search
Document Center

Mobile Platform as a Service:Integrate into Android

Last Updated:Nov 24, 2025

This article describes the procedure of integrating real device preview on Android.

Prerequisites

  • mPaaS has been activated and integrated.

  • The AntCubeTool of Ant Cube Card has been installed. For more details, please refer to: About AntCubeTool.

  • The integration process has been completed by referring to the Quick start.

Procedure

  1. Add dependencies for real device preview.

    1. Add the Ant Cube Card-Development Tool component.

    2. Add third-party dependencies to the build.gradle file of the main module of your project. If there are any conflicts, you can use the version of your dependency instead.

      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. Start the local debugging service by using the command line. In the path of the project, run the command to open the service. The instructions for enabling the service on macOS and Windows are as follows:

    • macOS: act prepare && act server

    • Windows: act prepare | act server

      After the instruction is executed, a QR code will be generated at the terminal.

  3. Start the client and scan the code to establish a connection. The terminal will prompt that the device is connected.

    CubeCardDebug.openScanner(activity); 

    Since it is an intranet connection, if the targetVersion is greater than 27, it needs to be downgraded, or configure android:usesCleartextTraffic="true" android:networkSecurityConfig="@xml/network_security_config" and the corresponding network_security_config.xml in the manifest.

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

    After scanning the code, a toast notification will appear on the client: Cube Socket: Connected.

    The terminal will also prompt that it is connected.

  4. Preview.

    Modify the card code, and then call the act build to complete the compilation. Then call act preview to push the compiled content to the client.