Current location - Quotes Website - Signature design - How to package html5 programs into Android applications
How to package html5 programs into Android applications

Problem analysis:

html5 website is mainly composed of html css js and needs to be displayed using a browser.

Android needs to be developed using Java language, which undoubtedly increases the difficulty for front-end engineers.

Subsequently, many packaging tools appeared to help us package web page elements into mobile apps and convert the html we wrote into Java language.

Solution:

Recommend a commonly used packaging tool: HBuilder.

This tool not only provides Android application packaging, but also can directly connect to the mobile phone for debugging. With HTML5, it can realize many native Android functions. For example: scan the QR code, take a photo, shake, etc.

Specific steps:

1. Real machine debugging

After entering the software, click "Run" in the first step, and click "Run on mobile phone" in the second step , the third step is to select the connected mobile phone. In the example, I use an Android emulator to connect. Several commonly used Android emulation machines on the market can be connected directly.

After following the above steps, packaging will be automatically performed and the application will be installed in the linked mobile phone (simulator). You can operate the mobile phone (simulator) for testing.

2. Package and generate the Android installation format apk file

① Open the software and select Release-gt; release as a native installation package, and the window below will open.

② Check the Android checkbox. If you use the Dcloud public certificate, you can package it directly and the phone can install it and use it. If you need to upload and distribute it to a third-party application platform, you need to use your own certificate. You can use Keytool, a tool that comes with JRE to create and manage digital certificates, to generate your own certificate. The generation process is free.

After checking the Android option, fill in the Android package name in the form below. To ensure uniqueness, you can use the reverse writing of your own website domain name plus the application name. If you use your own certificate, you also need to fill in the certificate alias, key password, and certificate file.

After completing the filling, click Package to generate an apk file.

Other notes:

1. During the development process, there is no need for packaging. Real machine debugging should be used more often, which can save a lot of time.

2. After development, try your best to test on various versions of Android machines, because the styles of some web pages have slightly different effects in different Android versions.

3. Re-edit the HTML5 website code and convert some webpage functions into mobile phone functions, such as tag jump of webpage elements, which should be completed using Webview. It can solve the problem of white screen when switching pages, and can also improve the efficiency of website operation on mobile phones.