gradle7.4上测试过
官网地址:https://developer.android.com/studio/projects/android-library
使用“Project Structure”对话框添加依赖项
在同一个项目中使用您的库
如需在同一项目中的另一个应用或库模块中使用新的 Android 库代码,请添加一个项目级依赖项:
- 依次转到 File > Project Structure > Dependencies。
- 选择要在其中使用库的模块。
- 在 Declared Dependencies 标签页中,点击 ➕,然后在下拉菜单中选择 Module Dependency。
4. 在“Add Module Dependency”对话框中,选择您的库模块。
-
选择需要此依赖项的配置,或选择“implementation”(如果模块适用于所有配置),然后点击“OK”。Studio 将修改模块的
build.gradle
文件,以添加以下形式的依赖项:
implementation(project(path: ":example-library"))