views:

116

answers:

3

Can an Android APK archive be imported into another Android project and accessed the same way as a JAR archive can?

+7  A: 

No, you can't use an APK like a JAR file.

If you want to share Android resources between projects you'll need to create an Android Library Project.

Dave Webb
Ok I will try that. Thank you!
travega
+1  A: 

No not in the way you would use a jar. If you have a java library that you want to import into your project you can simply add it as in any other java project.

If you have the project files of an app that you want to integrate in you application you can create an android library project out of this app. This enables you to build a R file for the layout objects and drawables etc. of the library that is also consistent in the project that includes this library project.

Janusz
+1  A: 

I think that you actually can at runtime (assuming read permissions) but you cannot resolve imports at the java compilation stage since you don't have any java class files, only dex class files that were made from them. So you'd need java stubs or "headers" to stand in for those functions during the java stage of compilation - or possibly try to "link" to them manually at runtime using reflection.

Chris Stratton