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
Add the real-time preview dependency.
Add the Cube Card-Developer Tool component.
Add the third-party dependencies to the
build.gradlefile 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' ······· }
Run the following command in your project's directory to start the local debugging service:
macOS:
act prepare && act serverWindows:
act prepare | act serverAfter you run the command, a QR code is generated in the terminal.
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 correspondingnetwork_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.
Preview
Modify the card's code and run
act buildto compile it. Then, runact previewto push the compiled content to the client.