Android如何引用其他工程
2012-03-13 18:08
253 查看
Referencing a library project
If you are developing an application and want to include the shared code or resources from a library project, you can do so easily by adding a reference to the library project in the application project's Properties.
To add a reference to a library project, follow these steps:
In the Package Explorer, right-click the dependent project and select Properties.
In the Properties window, select the "Android" properties group at left and locate the Library properties at right.
Click Add to open the Project Selection dialog.
From the list of available library projects, select a project and click OK.
When the dialog closes, click Apply in the Properties window.
Click OK to close the Properties window.
As soon as the Properties dialog closes, Eclipse rebuilds the project, including the contents of the library project.
Figure 2 shows the Properties dialog that lets you add library references and move them up and down in priority.
Figure 2. Adding a reference to a library project in the properties of an application project.
If you are adding references to multiple libraries, note that you can set their relative priority (and merge order) by selecting a library and using the Up and Down controls. The tools merge the referenced libraries with your application starting from lowest priority (bottom of the list) to highest (top of the list). If more than one library defines the same resource ID, the tools select the resource from the library with higher priority. The application itself has highest priority and its resources are always used in preference to identical resource IDs defined in libraries.
Declarations should reference the library components by their fully-qualified package names, where appropriate.
For example, the TicTacToeMain example application declares the library Activity
按如下方法设置:
1. 假设要引用的android工程叫LibProject,引入到的工程叫MainProject;
2. 设置LibProject,右键->Properties->Android,将Is library项选中,然后Apply;
3. 设置MainProject,右键->->Properties->Android, 在Library中,点击Add按钮,将LibProject工程加入,Apply即可。
设置完成后,在MainProject工程中能看到LibProject的代码等资源都已经引入进来。
本文转载自:http://blog.csdn.net/johnnywsd/article/details/6845451
If you are developing an application and want to include the shared code or resources from a library project, you can do so easily by adding a reference to the library project in the application project's Properties.
To add a reference to a library project, follow these steps:
In the Package Explorer, right-click the dependent project and select Properties.
In the Properties window, select the "Android" properties group at left and locate the Library properties at right.
Click Add to open the Project Selection dialog.
From the list of available library projects, select a project and click OK.
When the dialog closes, click Apply in the Properties window.
Click OK to close the Properties window.
As soon as the Properties dialog closes, Eclipse rebuilds the project, including the contents of the library project.
Figure 2 shows the Properties dialog that lets you add library references and move them up and down in priority.
Figure 2. Adding a reference to a library project in the properties of an application project.
If you are adding references to multiple libraries, note that you can set their relative priority (and merge order) by selecting a library and using the Up and Down controls. The tools merge the referenced libraries with your application starting from lowest priority (bottom of the list) to highest (top of the list). If more than one library defines the same resource ID, the tools select the resource from the library with higher priority. The application itself has highest priority and its resources are always used in preference to identical resource IDs defined in libraries.
Declaring library components in the the manifest file
In the manifest file of the application project, you must add declarations of all components that the application will use that are imported from a library project. For example, you must declare any<activity>,
<service>,
<receiver>,
<provider>, and so on, as well as
<permission>,
<uses-library>, and similar elements.
Declarations should reference the library components by their fully-qualified package names, where appropriate.
For example, the TicTacToeMain example application declares the library Activity
GameActivitylike this:
<manifest> ... <application> ... <activityandroid:name="com.example.android.tictactoe.library.GameActivity" /> ... </application></manifest>
按如下方法设置:
1. 假设要引用的android工程叫LibProject,引入到的工程叫MainProject;
2. 设置LibProject,右键->Properties->Android,将Is library项选中,然后Apply;
3. 设置MainProject,右键->->Properties->Android, 在Library中,点击Add按钮,将LibProject工程加入,Apply即可。
设置完成后,在MainProject工程中能看到LibProject的代码等资源都已经引入进来。
本文转载自:http://blog.csdn.net/johnnywsd/article/details/6845451
相关文章推荐
- Android如何引用其他工程
- Android如何引用其他工程
- Android如何引用其他工程
- 在android中如何引用其他工程
- android如何引用其他工程
- ****Android如何引用其他工程
- 原始XML文件如何引用Android项目中的其他资源
- Android项目中引用到其他工程
- android studio生成aar包并在其他工程引用aar包
- Android 工程引用其他Library工程时的R.id问题
- android 依赖工程 Android 工程引用其他Library工程
- Android 工程引用其他Library工程时注意事项
- eclipse Android 工程在Libs导入第三方jar / Android工程作为library为其他工程提供引用
- android 解决studio生成aar包并在其他工程引用aar包的坑,不需要任何gradle配置
- 如何解决android studio导入其他工程gradle不统一的问题
- Android项目中引用到其他工程
- Android项目中引用到其他工程
- android studio生成aar包并在其他工程引用aar包
- android studio生成aar包并在其他工程引用aar包的方法
- android studio生成aar包并在其他工程引用aar包