0

I've created an Android project that does some very simple network stuff. This project is standalone, and I've successfully exported it as a jar file and imported it into other projects I've worked on. When exporting this project, I am ONLY exporting the class files that are used for the project. (No system files: ie. Manifest, etc)

I want to leave this project as standalone since it is used in other projects and will be used more in the future.

However, we have other projects that need the features of the network jar and some other features. What I would like to do is create a new project, import the network jar file. Create wrappers for all the functions in the network jar file, then add more functionality.

Afterwards I want to package this project up as a jar file, so that I can use it solely for projects that require that extra functionality.

Having this project as a jar is important, because this component might be given to other people to use, and easy/simple integration is required.

This seamed like it should be pretty straight forward to me. But I am getting noClassDef errors and Verify errors.

I even stripped the project down to a single function that returns a static String from the original network jar and passed that through and still got a "could not find method xxxx referenced from method xxxx" log and then a unable to resolve static method warning, then a No ClassDefFoundError. Here's the logcat.

log

What is the proper way to do this?

Thanks!

4

1 回答 1

2

Jar files that want to use embedded jars must define a custom class loader, like JarClassLoader.

If you want to use a single jar file you also have options like OneJar, JarJar, and ProGuard.

于 2013-01-16T20:35:14.050 回答