eclipse的jar包引用和android.manifest的jar包引用区别

1eclipse中通过build path引入jar包,是引用的第三方的jar包,直接打包进apk中的(静态库)。

  关于此种jar包的引入方式,网上的总结很多,不再赘述。

 

2manifest.xml中引入jar

Ø  manifest.xml中引用jar包的方法:

<uses-library android:name="string"

             android:required=["true" | "false"] />

Ø  关于uses-library 标签的sdk文档说明如下:

Specifies a shared library that the application must be linked against. This element tells the system to include the library's code in the class loader for the package.

    All of the android packages (such as android.app, android.content, android.view, and android.widget) are in the default library that all applications are automatically linked against. However, some packages (such as maps) are in separate libraries that are not automatically linked. Consult the documentation for the packages you're using to determine which library contains the package code.

    This element also affects the installation of the application on a particular device and the availability of the application in Android Market:

    Installation

        If this element is present and its android:required attribute is set to true, the PackageManager framework won't let the user install the application unless the library is present on the user's device.

    Market

        Android Market filters applications based on the libraries installed on the user's device. For more information about filtering, see the topic Market Filters.

总结一下就是:这个标签用于告诉系统运行此apk时需要用到哪个库(动态库)

androidapi分为两类,①标准的 ②可选的。标准的android库(包含标准api)是默认自动连接的,比如:android.app, android.content, android.view,但是有些库(包含那些可选api)则不是,比如maps(Google map)

Ø  关于android:required属性,sdk文档说明如下:

Boolean value that indicates whether the application requires the library specified by android:name:

    "true": The application does not function without this library. The system will not allow the application on a device that does not have the library.

    "false": The application can use the library if present, but is designed to function without it if necessary. The system will allow the application to be installed, even if the library is not present. If you use "false", you are responsible for checking at runtime that the library is available.

    To check for a library, you can use reflection to determine if a particular class is available.

The default is "true".

也就是说如果设置为true,但是安装时发现该设备上并没有该库的话就会导致安装失败;若设置为false,则无论设备上是否含有该库,apk都将能够安装,但是用到此库中的功能时需要自己判断该库是否可用。默认情况下该值为true

你可能感兴趣的:(eclipse,android,jar,application,documentation,library)