Hbuilderx uniapp local packaging android project

The recent project uses uniapp as the mobile terminal, so it is written with hbuilderx. The code style can be said to be a mixture of WeChat applet syntax and Vue syntax.

Here is a record of the whole process of the pure uniapp project being packaged locally into an Android project through hbuilderx, so that it can be checked next time.

Some people may ask why not cloud packaging, although cloud packaging is very convenient, no need to download androidstudio or xcode, but security, although the official promise will not upload code, but some companies require absolute security and confidentiality, obviously do not use cloud packed.

1.APP related configuration

Open the manifest.json list configuration file in the uniapp project, and other configurations should be completed during the development stage. Configured on this basis, you can configure the version name, version number, application name, and AppID. If not, get it again.

Note: If it saves trouble, simply copying the AppID to others and letting others package it is not acceptable. It is necessary to add others to the collaborator or transfer the project

2. Export uniapp code

Select the project, then click on the top menu release --> Native App-Local Packaging --> Generate Local Packaged App Resources

Then you can sit and wait for the console to print and export successfully, and then you will see a folder composed of AppID.

3. Download android offline sdk (download it yourself)

Address:  Native Developer Support

4. Download and install AndroidStudio, this will be solved by yourself.

5. Import the sample Android project provided by the offline SDK

Note: The downloaded Android offline SDK corresponds to the local development tool version

 

6. Modify the package name

The package names in these two locations should be consistent

7. Import the file name composed of AppID packaged by Hbuilderx

In fact, just copy that folder directly, and then copy it to apps under the android assets file

Secondly, open dcloud_control.xml under the data folder under assets, which must be consistent with the AppID

8. Fill in appkey

If there is no appkey, go here to apply, the official tutorial link  Native developer support

 Then you need to fill in the SHA1 signed by the Android certificate

 In view of saving trouble and some developers are not android developers, then directly operate the menu

On your android studio have these menus

Select Build --> Generate Signed Bundle / APK...

 Select APK, then next next step

I have created it here before, so it has value. If you don’t have value, just click Create new...

Here is to fill in the signature certificate password you want to set, and some information about the signature

Generally, except for the password and Alias, it doesn't matter

But you should first click on the folder option to find a path to store the generated signature file. I usually put it in the project because I am afraid that I can’t find it. It’s up to you. 

After filling it out, it will be worth it this time

But don't worry, next we need to get the SHA1 to continue to apply for our AppKey

First, you can use cmd or the menu Terminal under android studio to open the command line, and locate the location of the signature file xxx.jks, then enter keytool -v -list -keystore ***.jks , and you will be prompted to enter the password. It is the password when the signature file was just created

Then you can see this, copy it, go back to the place where you just filled in and fill it in.

 

 

Then go back to Android's AndroidManifest.xml and fill in it

9. Package the release version apk

This is basically the end, the last thing is to package an apk, the steps are the same as the jks signature file just generated

Because there are already jks, just fill in these values, and then next

 The apk will be packaged. The apk is in the folder in the above picture, usually in the release folder of your project. This apk can be installed on the mobile phone to see the effect.

Well, I will write it here first this time, in case I forget to make a backup later. The next time you update the native android project, load the page written by uniapp in the form of h5, how to operate, how to interact. That is half native, half uniapp

My personal creation, if there is any similarity, it is purely coincidental, or contact me to make changes. Please reprint or CV combination to indicate the source, thank you! (If you have any questions or mistakes, please point them out, my QQ:752231513)

Guess you like

Origin blog.csdn.net/qq_30548105/article/details/125280991