Import Android APK archive?

流过昼夜 提交于 2019-12-22 07:07:16

问题


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


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/3658386/import-android-apk-archive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!