anticafe
anticafe

Reputation: 6892

Replace Android library project by JAR library?

In my project, there are many library project (more than 10). It takes long time to build. So I want to replace some of these library projects by JAR libraries.

According to this question: How to Convert an Android Library Project to an External JAR?

As CommonsWare's answer (https://stackoverflow.com/a/7973950/190309)

If your library is purely Java code, with no resources, you can create a JAR out of the .class files, just as you would with regular Java.

But when using NineOldAndroids library (https://github.com/JakeWharton/NineOldAndroids) from Jake Wharton,

This library is presented as a .jar file which you can include in the libs/ folder of your application.

It means although there are many resources in NineOldAndroids, I can use it as a JAR library instead.

With ADT 17, for every library project, there is a JAR library in lib_project/bin/lib_project.jar which automatically generated each time library project is built.

Can I use this JAR as an alternative for library project?

Upvotes: 1

Views: 1774

Answers (3)

k3b
k3b

Reputation: 14775

I have tried and documented this issue in how-to-consume-reusable-gui-element-widget-with-resources-in-android and i didn-t succeed with adt-17. but maybe i did something wrong.

CommonsWare-s answer to my qestion says

 > Eventually (which now appears like it will be the R18 version of tools or later), the 
 > tools should support packaging reusable components in a JAR, with resources, in 
 > such a manner that you can add them to a host project and the resources will 
 > be blended in automatically. Right now, that's not an option.

Upvotes: 1

njzk2
njzk2

Reputation: 39406

If you look into the jar generated for a library project, you'll see there is no resource in it. It is only used for the Java classes.

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1007533

It means although there are many resources in NineOldAndroids

There are precisely zero resources in NineOldAndroids. You can tell this by looking at the project and seeing that there is no res/ directory.

With ADT 17, for every library project, there is a JAR library in lib_project/bin/lib_project.jar which automatically generated each time library project is built.

Can I use this JAR as an alternative for library project?

Not at this time. That JAR still depends on the library project itself.

Upvotes: 3

Related Questions