[Huawei Developers] John Wo:
According to the introduction of Cocos Creator from its official website, Cocos Creator 2.4.1 and later versions support HUAWEI AppGallery Connect and have been providing multiple AppGallery Connect services. The following figure shows all supported AppGallery Connect services.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016063301.02879124344044932148008694901800:50511102062402:2800:6CA518A390474D1E6E609B2CEEE8C71C337E421095A1EA6D84FFE608DFA364B0.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016063301.02879124344044932148008694901800:50511102062402:2800:6CA518A390474D1E6E609B2CEEE8C71C337E421095A1EA6D84FFE608DFA364B0.png[/IMG]​

To test how well Cocos supports AppGallery Connect services, this article uses the App Performance Management (APM) service as an example to monitor the performance data of a Cocos-developed app. First, let's see what APM is.

AppGallery Connect APM

APM of AppGallery Connect provides minute-level app performance monitoring capabilities. You can view and analyze app performance data collected by APM in AppGallery Connect to comprehensively understand the performance features of developed apps, helping you quickly and accurately rectify possible performance problems and continuously improve user experience.

That is, APM can help you monitor your app performance data in a variety of scenarios, including app launch, page loading, and network request. We can assume that APM can quickly locate performance-related problems for games, which attach great importance to performance as it greatly affects user experience.

Before You Start

Downloading and Installing the Cocos Dashboard

1. The Cocos Dashboard is the GUI-based development tool provided by Cocos. You can download it from https://www.cocos.com/creator/ (latest version: 2.4.2).

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016063424.88298408471508331430292806288468:50511102062402:2800:A8F4B90920667424397D2609BC240F8CBA55D7D4D780C672650FC0D0C2920727.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016063424.88298408471508331430292806288468:50511102062402:2800:A8F4B90920667424397D2609BC240F8CBA55D7D4D780C672650FC0D0C2920727.png[/IMG]​

2. You need to install the Visual Studio as well to obtain the Cocos dependency package. The following figure shows the installation procedure.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016063501.93916599729044322896050941096852:50511102062402:2800:0CBF0C72DB3CEE67C619D18199D72E9EFA95172FB338A5AD564A6DEDBE4446F2.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016063501.93916599729044322896050941096852:50511102062402:2800:0CBF0C72DB3CEE67C619D18199D72E9EFA95172FB338A5AD564A6DEDBE4446F2.png[/IMG]

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016063601.26887360964279436562303057133199:50511102062402:2800:58CBED8CEA2C185CBE628AF6B92EB43B5FE2910E7610742ED803F7AB2253C161.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016063601.26887360964279436562303057133199:50511102062402:2800:58CBED8CEA2C185CBE628AF6B92EB43B5FE2910E7610742ED803F7AB2253C161.png[/IMG]​

3. After the installation is complete, click Run

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016063655.37521066911427797954383048121516:50511102062402:2800:C33E6A99748DF35C747363B9D7631BF8111DFECEE7D515B1DBEF6D07438D2377.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016063655.37521066911427797954383048121516:50511102062402:2800:C33E6A99748DF35C747363B9D7631BF8111DFECEE7D515B1DBEF6D07438D2377.png[/IMG]​

Downloading and Installing Cocos Creator

1. Open the Cocos Dashboard and click Signin in the upper right corner. You can sign up first if you do not have an account.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016064036.13167398310667365425513159971340:50511102062402:2800:ED18E72DDCF367F9E16E6170E24D6E6B80DC31E9331119B4F6EE24EF6E99C6EE.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016064036.13167398310667365425513159971340:50511102062402:2800:ED18E72DDCF367F9E16E6170E24D6E6B80DC31E9331119B4F6EE24EF6E99C6EE.png[/IMG]​

2. After sign-in, click Editor on the left, and then click Download in the lower right corner.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016064106.15784307013123759643868314089933:50511102062402:2800:E4D4B6B772E2C09F531F68FE003D56AA155673D7C3E2745BF3F8593412EDCFC4.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016064106.15784307013123759643868314089933:50511102062402:2800:E4D4B6B772E2C09F531F68FE003D56AA155673D7C3E2745BF3F8593412EDCFC4.png[/IMG]​

3. On the Editor page, select the latest version of Cocos Creator, click the download button on the right, and agree with the terms.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016064136.53690057379807316494619882578810:50511102062402:2800:55116DEDF7AC9832C3832538BD0027D9FCBB71C063F602D69FC00784AB55D771.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016064136.53690057379807316494619882578810:50511102062402:2800:55116DEDF7AC9832C3832538BD0027D9FCBB71C063F602D69FC00784AB55D771.png[/IMG]​

4. Once the download is complete, you can create a Cocos project on the Project page. Take a HelloWorld project as an example.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016064156.60160913661407571648431273082869:50511102062402:2800:C1305E3BD51117BC10D91CA2E4B091E51835ABFA953356F511C1BE3C12C22F03.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016064156.60160913661407571648431273082869:50511102062402:2800:C1305E3BD51117BC10D91CA2E4B091E51835ABFA953356F511C1BE3C12C22F03.png[/IMG]​

5. When you open the project for the first time, the system prompts you to select a language. Just select English. Select the corresponding running environment and click Run.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016064213.65735507593622984522039976534784:50511102062402:2800:BF52CAE57E24CCAB0FA16D660E98F586167DEAE25C560442B7EA5277A1378D33.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016064213.65735507593622984522039976534784:50511102062402:2800:BF52CAE57E24CCAB0FA16D660E98F586167DEAE25C560442B7EA5277A1378D33.png[/IMG]​

Configuring the Visual Studio Code Compilation Environment

The built-in code editor of Cocos is too simple and is only suitable for code viewing and a small amount of editing. Therefore, we need a more mature and powerful compilation environment. This is where Visual Studio Code comes in.

1. Download and install Visual Studio Code of the required version based on your computer environment.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016064254.41569722105978274729043660082082:50511102062402:2800:FBAA38CDEAF53198EFD6E5BEF8863556FBFC83D691348825875D0A257127782D.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016064254.41569722105978274729043660082082:50511102062402:2800:FBAA38CDEAF53198EFD6E5BEF8863556FBFC83D691348825875D0A257127782D.png[/IMG]​

2. Open your project in Cocos Creator and choose Developer > VS Code Workflow > Install VS Code Extension from the main menu to add an adaptation plug-in to Cocos Creator.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016064311.17008990970437638213144706898021:50511102062402:2800:38AC54937879B63770DEF92EE1272CE33B0D124836A72391D5D94CDC8C9723ED.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016064311.17008990970437638213144706898021:50511102062402:2800:38AC54937879B63770DEF92EE1272CE33B0D124836A72391D5D94CDC8C9723ED.png[/IMG]​

3. If the information shown in the following figure is displayed, the installation is successful.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016064334.02851197695560226319338897436461:50511102062402:2800:1626F9D5955029E01B5272ED8D0E467D648292F58D8BB9EA4AF73EBD28DB1D56.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016064334.02851197695560226319338897436461:50511102062402:2800:1626F9D5955029E01B5272ED8D0E467D648292F58D8BB9EA4AF73EBD28DB1D56.png[/IMG]​

4. If you want the system to autocomplete the Cocos Creator engine API during coding, you need to generate the API autocompletion data and put the data in the project path through the menu. Choose Developer > VS Code Workflow > Update VS Code API Source.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016064414.68785311217484180650477156805952:50511102062402:2800:AE8DC350D03CA1A3FBD69E090712C065C502A7C3784AAF8D91257F558865F24F.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016064414.68785311217484180650477156805952:50511102062402:2800:AE8DC350D03CA1A3FBD69E090712C065C502A7C3784AAF8D91257F558865F24F.png[/IMG]​

5. Double-click the HelloWorld.js script in the project directory. In the dialog box that is displayed, click Yes and select Visual Studio Code as the default editor.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016064430.43400108785885310676756976522646:50511102062402:2800:CCFCD934C0173FD49BFB3A67CAC9CFB876B47B1339C3CBB8ED3E8B3FDE1B473D.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016064430.43400108785885310676756976522646:50511102062402:2800:CCFCD934C0173FD49BFB3A67CAC9CFB876B47B1339C3CBB8ED3E8B3FDE1B473D.png[/IMG]​

6. Double-click the HelloWorld.js script again to develop your app.

Packaging and Releasing a Cocos-based App in AppGallery Connect

Cocos Creator 2.4.1 and later versions allow you to package and release your app to HUAWEI AppGallery through AppGallery Connect. In addition, Cocos Creator suports various AppGallery Connect services, such as APM, which can be quickly integrated and used. The detailed procedure is as follows:

1. Sign in to AppGallery Connect and create an app.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016070244.98150273420124348756420388425908:50511102062402:2800:0E90226D7944C5355661B23B231E857116F7AF5E4F193C6008A24882494E0037.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016070244.98150273420124348756420388425908:50511102062402:2800:0E90226D7944C5355661B23B231E857116F7AF5E4F193C6008A24882494E0037.png[/IMG]​

2. Sign in to Cocos Creator, choose Project > Build…, and select HUAWEI AppGallery Connect as the release platform.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016070257.35733493450947006196132011789489:50511102062402:2800:78C6881F70D8B64DF3065807CD9D9DD0384BF8E6FA5C035306DE1B8DC639FF62.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016070257.35733493450947006196132011789489:50511102062402:2800:78C6881F70D8B64DF3065807CD9D9DD0384BF8E6FA5C035306DE1B8DC639FF62.png[/IMG]​

3. Click Build. If Built huawei-agc successfully is displayed, the build is successful.

Note: When you build a project for the first time, you need to choose File > Settings… and configure the Android SDK path and NDK path on the native development environment page.

4. Click Compile and wait until the compilation is successful.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016070329.15710576369749241825155912588382:50511102062402:2800:31EF0C7048867294C7992D4D0B4C4E319E60C6919E0A4EA69850B4F2D33155E7.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016070329.15710576369749241825155912588382:50511102062402:2800:31EF0C7048867294C7992D4D0B4C4E319E60C6919E0A4EA69850B4F2D33155E7.png[/IMG]​

5. A jsb-default or jsb-link directory (depending on the template selected on the Build… panel) is generated in the build directory of the default release path. AppGallery Connect services are automatically integrated in the directory. Open the publish directory in the jsb-link directory to view the generated APK file.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016070355.05180074902375509502793605661606:50511102062402:2800:0C681755279F0B812CDB425B2388D3D53E7C6141B57B89C748D79DA6DB1DD790.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016070355.05180074902375509502793605661606:50511102062402:2800:0C681755279F0B812CDB425B2388D3D53E7C6141B57B89C748D79DA6DB1DD790.png[/IMG]

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016070411.95323702297733018995944041169861:50511102062402:2800:56E59EF0513BB8AD10CC799B9D5A8B8AB2C634FFE2B77501A9264044A530BB14.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016070411.95323702297733018995944041169861:50511102062402:2800:56E59EF0513BB8AD10CC799B9D5A8B8AB2C634FFE2B77501A9264044A530BB14.png[/IMG]​

6. Upload the packaged APK file locally or using AppGallery Connect.

l Uploading the file on the Upload... panel.

a) Login Type: OAuth

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016070526.78272607959193702793211284552608:50511102062402:2800:54E8E40D465004B6F34FB3A34E716C76CA10F0BCE52507E9822D50755869D8D5.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016070526.78272607959193702793211284552608:50511102062402:2800:54E8E40D465004B6F34FB3A34E716C76CA10F0BCE52507E9822D50755869D8D5.png[/IMG]​

Click Confirm, sign in to your HUAWEI ID (with sufficient permissions), and select the check box of the corresponding permissions. The APK file will be uploaded automatically.

b) Login Type: API Client

Sign in to AppGallery Connect to obtain related configuration. Go to Users and permissions > Connect API > Create, create an API client, select a role as required, and click OK.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016070644.08856935403554814739945042164254:50511102062402:2800:96590C5729B4566BA7F7A5118BCE3AF3FE07CABFA6D8F392A104C57EC2F62647.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016070644.08856935403554814739945042164254:50511102062402:2800:96590C5729B4566BA7F7A5118BCE3AF3FE07CABFA6D8F392A104C57EC2F62647.png[/IMG]​

Enter your client ID and key of the API client in the text boxes on the Upload... panel in Cocos Creator. Click Confirm.

After the APK file is uploaded successfully, you can view it in AppGallery Connect.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016070709.38784308808883074043640624977153:50511102062402:2800:07E12BCA335732A7159C1FF25406A95EB9E8FE641124980EBB6721F8996129EA.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016070709.38784308808883074043640624977153:50511102062402:2800:07E12BCA335732A7159C1FF25406A95EB9E8FE641124980EBB6721F8996129EA.png[/IMG]

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016070758.56236091424181989853247793272773:50511102070101:2800:ECB5C7BC0B90030AB54752C5D36BBAC7924842F52A87B025B86059596CBF4CB3.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016070758.56236091424181989853247793272773:50511102070101:2800:ECB5C7BC0B90030AB54752C5D36BBAC7924842F52A87B025B86059596CBF4CB3.png[/IMG]​

Uploading the file in AppGallery Connect

Click Upload and select the APK generated by Cocos Creator.

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016070827.99862468591228070348600330604688:50511102062402:2800:EA09C6A78BCD0C2C95ADAC8A4286BF2849F76A74F074D245871E64F2EAC2FB84.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/006/560/358/2640852000006560358.20201016070827.99862468591228070348600330604688:50511102062402:2800:EA09C6A78BCD0C2C95ADAC8A4286BF2849F76A74F074D245871E64F2EAC2FB84.png[/IMG]​

For more details, please refer to:

Cocos official documents

AppGallery Connect APM development guide

AppGallery Connect console

GitHub to download demos and sample codes

Stack Overflow to solve any integration problems​