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)
an00b
  • 11,338
  • 13
  • 64
  • 101

3 Answers3

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/

Doug Stephen
  • 7,181
  • 1
  • 38
  • 46
  • @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"? – an00b Jun 20 '11 at 16:20
  • @an00b No problem. Don't forget to award the bounty though... I wants me some rep :) – Doug Stephen Jun 20 '11 at 17:42
  • @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. – an00b Jun 20 '11 at 19:11
  • Heh no worries. I ran up on the sane thing first time I awarded a bounty. I thought it was automatic too. – Doug Stephen Jun 20 '11 at 20:14
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.

jkhouw1
  • 7,320
  • 3
  • 32
  • 24
  • 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](http://stackoverflow.com/questions/6325826/unable-to-instantiate-activity-caused-by-classnotfoundexception)) is what differentiates an Application package from a Library package "under the cover". – an00b Jun 13 '11 at 16:24
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.

Ferry de Boer
  • 71
  • 1
  • 5
  • 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)? – an00b Jun 14 '11 at 12:55