Rami
Rami

Reputation: 2148

How to import specific classes from a whole jar?

I want to use Blob class from appengine-api-1.0-sdk-1.6.3.jar in my android Project.
Now importing to whole jar terminates the app at apk installation. And also nor reasonable appengine-api-1.0-sdk-1.6.3.jar weights 23 MB.

How can i import only the specific classes from the jar using Eclipse without importing the whole jar?

Upvotes: 0

Views: 546

Answers (2)

Will
Will

Reputation: 7017

This is a brute-force approach, but you could definitely repackage the jar and remove the classes you do not need. Be sure to account for dependencies if any (include Blob and its dependencies, including their dependencies, etc.). Jars are effectively .zip files, so create an empty jar (zip), add dependencies as necessary, rezip (if unzipped), rename (if necessary). I don't know if Android provides a filtering mechanism, but you could put the above steps in an automated build script. If you are using Maven you could probably leverage the jar plugin to do this.

Upvotes: 1

LaGrandMere
LaGrandMere

Reputation: 10359

Unzip the jar, take the class only and put it in your classpath.

Upvotes: 3

Related Questions