Home » Android » android – What does checking the "is Library" checkbox do "Under the Cover"?

android – What does checking the "is Library" checkbox do "Under the Cover"?

Posted by: admin June 15, 2020 Leave a comment

Questions:

I noticed that when I convert an existing Android Application project to an Android Library project by checking the “is Library” checkbox, nothing changes in the project’s source code or XML files.

So what really happens when the “is Library” checkbox is checked? What changes internally, in the package and/or project files? Where can I learn more about this?

To better explain my question:

  1. What I am interested to know (mainly
    for troubleshooting purposes) is
    what differentiates an Application package from a Library
    package “under the cover”?
  2. Is the fact that a project is
    “Library Project” marked
    somewhere
    ? If so, where does it
    mark it (obviously not in the source
    files and not even in the res XML
    files)
How to&Answers:

From the Managing Projects from the Command Line page:

The create lib-project command creates
a standard project structure that
includes preset property that
indicates to the build system that the
project is a library. It does this by
adding this line to the project’s
default.properties file:

android.library=true

In other words, it’s a property that is utilized by the build system and not by the operating system.

UPDATE: I’m on my iPhone so I won’t type out a whole paraphrase, but here’s a pretty good blog article discussing the differences between a Java JAR and an Android Library Project, including how the dex tools add the resources and dex code to the .apk:

http://devmaze.wordpress.com/2011/05/22/android-application-android-libraries-and-jar-libraries/

Answer:

From the devsite: http://developer.android.com/guide/developing/projects/projects-eclipse.html

You can also designate an Android
project as a library project, which
allows it to be shared with other
projects that depend on it. Once an
Android project is designated as a
library project, it cannot be
installed onto a device.

Answer:

A library project isn’t packaged as a seperate redistributable file as you’re used to with a jar. It’s merged with the the apk file of your application.

The page you linked to mentions it in the Referencing a library project section.

As soon as the Properties dialog closes, Eclipse rebuilds the project, including the contents of the library project.