How to Package Multiple Android projects into an APK

Source: Internet
Author: User

How to Package Multiple Android projects into one APK (how to reference other projects in your Project ).
How does one Package Multiple android projects into an apk? The principle is that a main project references other projects, and other projects are referenced like jar packages, of course, it is quite different from the jar reference principle. The following is a detailed description. Most of them are translated articles on the official website development wizard.
Step 1: set a common android project as a library project
The Library Project is also a standard android project, so you should first create a common android project. This project can start with any name, registration, and other fields to be set, as shown in 1.
Set the project as a database project. The procedure is as follows:
1. In Package Explorer, right-click the project folder and click Properties.
2. In the Properties window, select "Android" and display the Library property in the lower right corner.
3. Select "is Library" single region and click Apply.
4. Click OK to close the Properties window.
In this case, the project becomes a library project.
Of course, the java project can also be converted into a library project, which is very simple. Execute the above four steps. Other Program projects can reference the library project.
 
Figure 1. Make a project a library project
Create a manifest File
The manifest file of a library project is the same as that of a standard android Application, declaring all shared components.
For example, in the example of TicTacToeLib in APIDemo, the Library Project declares Activity GameActivity:
<Manifest>... <application>... <activity android: name = "GameActivity"/>... </application> </manifest>
If the application you develop wants to include the code and resources in the library project, the reference steps are as follows:

1. In Package Explorer, right-click the project folder and click Properties.
2. In the Properties window, select "Android" and display the Library property in the lower right corner.
3. Click Add to open the Project Selection dialog box.
4. Select a project from the list of available database projects and click OK.
5. Close the dialog box and click Apply (in the Properties window ).
6. Click OK to close the Properties window.
After completing the above six steps, Eclipse will recreate the project and include the content in the library project. 2.
 
Figure 2. Let the project reference a library project
If you want to add references to multiple library projects, you can use up and down to set their relative priority and merge order. When the tool merges referenced databases, the order is from low-priority (below the List) to high-priority (above the list ). If more than one database defines the same resource ID, this tool selects a resource with a higher priority. The application itself has the highest priority, and its resources zThe application itself has highest priority and its resources are always used in preference to identical resource IDs defined in libraries.
Declare the components in the library in the menifest File
In the manifest file, you must add all the components in the library project used in the current program. For example, you must declare any <activity>, <service>, <extends ER>, <provider>, <permission>, <uses-library>, similar to other elements.
When declaring components in a library project, you must use the full name of the class containing the package name.
In the TicTacToeMain example, declare the library Activity GameActivity:

<Manifest>... <application>... <activity android: name = "com. example. android. tictactoe. library. gameActivity "/>... </application> </manifest> For more information about the manifest file, see the documentation for AndroidManifest. xml.

 

From freeliver54
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.