The Mini Program IDE lets you preview and debug your code on a real device. This topic describes this process and the interfaces involved.
Prerequisites
Before you can preview and debug on a real device in the Mini Program IDE, ensure that your Android Mini Program has integrated this feature. For more information, see MriverDebug debug API.
Procedure
Open the
config.jsonconfiguration file for the Mini Program IDE from the mPaaS console, and find thedebug_urlfield.The following is a sample configuration file:
{ "login_url":"https://mappcenter.cloud.alipay.com/ide/login", "uuid_url":"http://cn-hangzhou-mproxy.cloud.alipay.com/switch/uuid", "debug_url":"wss://cn-hangzhou-mproxy.cloud.alipay.com", "sign":"3decfd66c2924489204b4b0f38a9c228", "upload_url":"https://mappcenter.cloud.alipay.com/ide/mappcenter/mds" }Set the debug address using
setWssHostand add/host/to the end of the address, as shown in the following example.MriverDebug.setWssHost("wss://cn-hangzhou-mproxy.cloud.alipay.com/host/");Click Preview or Real Device Debug in the upper-right corner of the IDE.
The IDE generates a
.zippackage from the current code and uploads it to the console.The console automatically creates a publishing task, generates a QR code, and returns it to the IDE.
NoteThe QR code may fail to generate if the whitelist is not configured correctly. For more information, see Whitelist settings.
Scan the QR code in the IDE using your mobile client. This action triggers the console to send the Mini Program package.
The QR code is valid for 15 minutes. After it expires, a Refresh button appears.
After the mobile client receives the Mini Program package, the preview or debug interface opens on the device.
Interface description
This section describes the interfaces and parameters for previewing and debugging on a real device, along with code examples.
MriverDebug.debugAppByScan(Activity activity)
This interface lets you preview and debug a Mini Program using the built-in mPaaS scanner.
Code example
MriverDebug.debugAppByScan(MainActivity.this);Parameter description
Name | Type | Description | Required |
activity | Activity | The current Activity. | Yes |
MriverDebug.debugAppByUri(Activity activity,Uri uri)
This interface lets you navigate to a Mini Program using a custom scanner. We recommend that you navigate to the activity of the page that launches the Mini Program.
Code example
MriverDebug.debugAppByUri(MainActivity.this,intent.getData()); Parameter description
Name | Type | Description | Required |
activity | Activity | The current Activity. | No (Recommended) |
uri | Uri | The data returned from the QR code scan. | No |