我学习构建一个可以与不同的项目中使用Android的共享库。我有关于这方面的一些问题。我进入问题之前,以下是我迄今所做的:
I am learning to build Android shared libraries that can be used with different projects. I got a few questions regarding this subject. Before I go into the questions, below is what I have done so far:
创建一个库项目创建另一个应用程序项目,进口上述库作为一个模块我的问题是:
是库项目的code自动与一个导入应用项目同步?如何能实现?如果没有,我能做些什么,以确保我只需要更新一次共享库?我使用的Android Studio IDE中。
I am using Android Studio IDE.
感谢您,
是啊,这可以在许多情况下是非常有帮助的。您可以执行以下操作来实现这一目标。
Ah yes, this can be very helpful in many cases. You can do the following to achieve this.
让我们假设你有两个项目 - 所有MyApplication 和 MyLibraryDemo 包含库模块的 libmodule 与以下路径:
Let's say you have two projects - MyApplication and MyLibraryDemo containing the library module libmodule with the following paths:
所有MyApplication - /../ AndroidStudioProjects / MyApplication的
MyLibraryDemo - /../ AndroidStudioProjects / MyLibraryDemo
libmodule - /../ AndroidStudioProjects / MyLibraryDemo / libmodule
和假设你正在尝试使用 libmodule 在所有MyApplication 。然后,在你的 settings.gradle
你的所有MyApplication
的项目,做到这一点。
And let's say you are trying to use libmodule in MyApplication.
Then, in your settings.gradle
of your MyApplication
project, do this
include ':app', ":libmodule"
project(':libmodule').projectDir = new File(settingsDir, '../MyLibraryDemo/libmodule')
您可能不得不作出更正相关,但我希望连接其它模块的想法是清楚的。
You may have to make relevant corrections, but I hope the idea of linking another module is clear.
所有最好的:)