Cocos creator 3.x packaging and building native Android APK process (packing release version, modifying APP icon)

This article introduces how cocos creator 3.x packs and builds the native Android APK. At the beginning, it followed the construction example on the official website, and found that there were various SDK version problems. Because there is no research on native Android, we can only think about it. Finally, it is barely packaged... Write an article to record the process, so as not to forget it later... If there is something wrong, please correct it in the comment area, and you can ask questions, but I may not be able to answer hhh...

1. Configure the environment

The first is to configure the native environment of Android, you need to install Android Studio , this can refer to the official documentation of cocos (https://docs.cocos.com/creator/manual/zh/editor/publish/android/build-setup-evn-android .html)
There will be no problem with this step according to the document

2. cocos build release

insert image description here
insert image description here
You can try to use the debug key for the first time. If you want to release the release, you need to use the keystore. This keystore is generated in Android Studio, which will be described later. insert image description hereAfter the configuration is complete, click Build and wait for completion.

3. Use Android Studio to package

Open Android Studio, File-Open-select the directory that was just built, click the little green robot file
insert image description here
and wait for Android Studio to load, there will be a bunch of error reports if nothing else, and a prompt to upgrade the version may appear in the lower right corner, just ignore it and close it.
Next, modify the Android Studio configuration, File-Settings as shown in the figure:
insert image description here
Apply, OK.
Then File-Project Structure checks the version number.
insert image description here
At this time, reload the project, the error should be gone, try to pack an APK:
insert image description here
wait for the compilation to complete, a dialog box will pop up in the lower right corner, click locate to locate the successfully packaged debug version of the APK, and test it in the simulator Effect.

4. Release the release version of the APK

If the above 3 steps are all right, you can try to package the release version of the APK. Open Android Studio, click Build menu - Generate Signed Bundle/APK
insert image description here

Select APK-Next
insert image description here
here and follow the official documentation. Path is the path to generate the key, which can be generated in the root directory of the project. After the
insert image description here
creation is completed, build it again in cocos creator (it seems that the release of Android does not allow modification of the build, and you need to build another New), cancel the check box of the debug keystore, fill in the keystore configuration, the path is the key file just generated, and the keystore alias is Alias ​​in the above figure.
insert image description here
Click Build again, wait for the build to be completed, and open it with Android Studio (note that the path generated by the second build is selected) to
open the project structure, configure the application as shown in the figure
insert image description here
, and then click view-tool Windows—build variants in turn, and the following appears to be
insert image description here
changed to Release
and then Build Apk again
insert image description here
. If nothing else happens, it will be the Release version of the APK after packaging.

5. Modify the APP icon

This is the easiest, locate to D:\cocos\WhackMole_taptap (your project name)\native\engine\android\res,
insert image description here
modify and replace the icons in these five folders, click the properties of the original icon to see the ratio, click on the picture above There are 5 types of order, namely 72 72, 48 48, 96 96, 144 144, 192*192. Make your own icons into these ratios and cover them, and Android Studio builds the apk again.
To make pictures, those who are not familiar with PS can use Kaitubao , upload pictures-modify size-customize size, and generate the above five types.

Guess you like

Origin blog.csdn.net/hangsky1990/article/details/131740544