Main project merges library manifest in eclipse

来源:互联网 发布:办公网络 编辑:程序博客网 时间:2024/05/16 11:28

一、背景

        通常情况下,eclipse中,主项目引用library,直接在主项目的AndroidManifest.xml中声明所有的组件,忽略library下的AndroidManifest.xml。如果是简单的工程,这样的做法简洁清晰,当然最好。但是,当工程包含多个libraries时,这样会降低主项目的AndroidManifest.xml可读性。

二、manifestmerger属性

        在主项目的project.properties里面设置manifestmerger.enable=true,这样主项目就会merge library的AndroidManifest.xml。

如:

# Project target.target=android-14
manifestmerger.enable=trueandroid.library.reference.1=xxxxxxandroid.library.reference.2=xxxxx

三、Application声明冲突处理

       当主项目和library的AndroidManifest.xml都声明了自定义的Application时,编译的时候会有冲突,这时编译器建议使用tools:replace进行覆盖。

如,在主项目中:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    package="com.test.hello" >    <uses-sdk        android:minSdkVersion="9"        android:targetSdkVersion="10" />    <application tools:replace="android:icon,android:label,android:name"        android:name="com.test.hello.myApplication"        android:icon="@drawable/icon_launcher"        android:label="@string/app_name" >    </application></manifest>

0 0
原创粉丝点击