Reputation: 6268
As I have understood I can create the classic .jar library for the Android as long as the library contains the java code. Once I will need to include the resources (xml files, etc.) to the library I need to create so called Android library.
The Android library is like the normal Android application project, but has the flag android.library
(in default.properties
file ) set to true
.
To use the Android library in my project first I need to have its java sources, then I need to have the library project loaded in Eclipse and then I have to add reference to the library project them from my application project in Eclipse menu:Properties>Android>Libraries
. This steps add the android.library.reference.x
into my application default.properties
file. Doing that the library java files are compiled and merged during the build procedure into final application dex file.
If I use the classic jar library (which can be made only if I use only Java code inside) it is enough only to add reference to the library .jar file in my application. This is done by specifying the project's Build Path. Later during the build process the jar file is merged with my application class files in order to create the final .dex file.
Please comment Thanks a lot
STeN
Upvotes: 0
Views: 647
Reputation: 1006674
Is my description correct?
More or less.
Do I really need to distribute sources to allow others to use my Android library ?
There are workarounds for this, but at the present time the expectation is that you will distribute source code. The only way to avoid it is to not refer to your own resources directly from your code (e.g., R.layout.foo
), but to either take resource IDs as parameters to methods or do runtime lookup of the resource IDs (e.g., getResources().getIdentifier()
).
A future edition of the Android build tools will support binary-only Android library projects. I believe this is presently targeted for the r17 release, slated for early 2012.
Upvotes: 2