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
- in the in Package Explorer , right-click the project folder, tap Properties .
- in the Properties window , select "Android", Library the properties are displayed at the bottom right.
- Click Add to open the Project Selection dialog box.
- Select an item from the list of available library items and click OK.
- After the dialog box is closed, click Apply (in the Properties window).
- 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