Best way to package a class for use in another app?
I've written a开发者_如何学Pythonn Android app which various abstract classes that perform useful functions. These functions could be leveraged in other apps.
I want to share a class module with another programmer, but I don't want to share the source code. I would like to share a .class file but I'm not sure how to do the following:
- Compile an Android .java file into .class
- What does the receiver of the .class file have to do to use that .class in their project? (using Eclipse environment)
You'll probably want to create a JAR. There's a lot of information about how to do this in Eclipse. See this how-to for a start. Basically, you just go to File->Export->Jar File. For the import side, see How to Add JARs to Project Build Paths in Eclipse (Java).
However, you should realize that it's quite easy to decompile Java classes.
You would share it using a .jar file. Eclipse has a wizard for exporting your classes as a jar file.
To import it into your Android project in Eclipse:
https://developer.android.com/guide/appendix/faq/commontasks.html#addexternallibrary
精彩评论