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
Add dependencies for real device preview.
Add the Ant Cube Card-Development Tool component.
Add third-party dependencies to the
build.gradlefile 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' ······· }
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 serverWindows:
act prepare | act serverAfter the instruction is executed, a QR code will be generated at the terminal.
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 correspondingnetwork_security_config.xmlin 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.
Preview.
Modify the card code, and then call the
act buildto complete the compilation. Then callact previewto push the compiled content to the client.