What does checking the "is Library" checkbox do "Under the Cover"?
Asked Answered
O

3

8

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)
Ollieollis answered 13/6, 2011 at 16:11 Comment(0)
E
6

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/

Endocrine answered 20/6, 2011 at 15:57 Comment(4)
@Doug Stephen +1 already for answering question #2. Do you also happen to know what differentiates an Application package from a Library package "under the cover"?Ollieollis
@Ollieollis No problem. Don't forget to award the bounty though... I wants me some rep :)Endocrine
@Doug Stephen I thought the bounty is automatically awarded to the accepted answer. Apparently this isn't the case. I just tried to click the +50 icon to award the bounty, but SO says I can only do it in 20 hours.Ollieollis
Heh no worries. I ran up on the sane thing first time I awarded a bounty. I thought it was automatic too.Endocrine
D
5

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.

D answered 13/6, 2011 at 16:20 Comment(1)
That's from the link that I posted in my question, but it doesn't explain what happens internally. Sorry for not explaining my question well. What I am interested to know (mainly for troubleshooting purposes) is what differentiates an Application package from a Library package "under the cover".Ollieollis
E
1

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.

Eno answered 13/6, 2011 at 19:23 Comment(1)
Thanks and +1 for highlighting this. What I am trying to understand is whether the fact that a project is "Library Project" is marked somewhere? If so, where does it mark it (obviously not in the source files and not even in the res XML files)?Ollieollis

© 2022 - 2024 — McMap. All rights reserved.