How to package multiple Android project as an apk

Source: Internet
Author: User

How to package multiple Android projects into an APK (how your project refers to other projects).
How to package multiple Android project into an apk, in fact, a master project referencing other project, other project is similar to the jar package is referenced, of course, and the jar reference principle is very different. The following is a detailed description.
The first step is to set up normal Android project as a library item
The Library project is also a standard Android project, so you first create a normal Android project. This item can be any name, any registration, set other fields that need to be set, etc., as shown in 1.
then set up the project as a library project with the following steps
1. In the Package Explorer, right-click the project folder and tap Properties.
2. In the Properties window, select "Android" and the Library properties are displayed on the bottom right.
3. Select the "Is Library" Radio box and click Apply.
4. Click OK to close the Properties window.
at this point, the project becomes a library project.
of course, the Java project can also make it into a library project, which is very simple and performs the four steps above. Other program projects can reference the Library project.

Create a manifest file
The manifest file for a library project also declares all shared components as standard Android applications.
For example, Tictactoelib in Apidemo, the library project declares the activity gameactivity:
<span style= "FONT-SIZE:14PX;" ><manifest> ...  <application> ...    <activity android:name= "gameactivity"/>    ...  </application></manifest></span>


Referencing library items

If you are developing an application that wants to include code and resources in a library project, it is very simple to refer to the following steps

  1. in the in Package Explorer , right-click the project folder, tap Properties .
  2. in the Properties window , select "Android", Library the properties are displayed at the bottom right.
  3. Click Add to open the Project Selection dialog box.
  4. Select an item from the list of available library items and click OK.
  5. After the dialog box is closed, click Apply (in the Properties window).
  6. Click OK to close the Properties window.

By completing the six steps above, Eclipse will rebuild the project and include the contents of the Library project. 2 is shown



If you want to add references to multiple library projects, use up and down to set their relative precedence and merge order. When the tool merges the referenced libraries, the order is from the lower priority (below the list) to the high priority (above the list). If more than one library defines the same resource ID, the tool chooses a resource with a high priority. The application itself has the highest precedence, its own resources zthe application itself has highest priorities and its resources is always used in preference to Identi Cal resource IDs defined in libraries. declaring components in a library in a menifest file
In the manifest file, you must increase all the components in the library project that are used in the current program. For example, you must declare any use of <activity>, <service>, <receiver>, <provider> et, <permission>, < Uses-library>, and other similar elements.
When declaring a component in a library project, you must use the full name of the class that contains the package name.
In the Tictactoemain example, the Declaration library activity gameactivity:
<manifest> ...  <application> ...    <activity android:name= "com.example.android.tictactoe.library.GameActivity"/>    ...  </application></manifest>


How to package multiple Android project as an apk

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.