简体   繁体   English

Android studio - 链接外部库

[英]Android studio - link external library

I'm having issues with linking the library to Android studio the correct way.我在以正确的方式将库链接到 Android 工作室时遇到问题。 I created external library and tried to link it to my project.我创建了外部库并尝试将其链接到我的项目。 What I actually did (not intended) was importing library but rather as a clone.我实际上做的(不是有意的)是导入库,而是作为一个克隆。
As a final result now there is duplicated source for my lib, one in actual library, one in project as imported module.作为最终结果,现在我的库有重复的源,一个在实际库中,一个在项目中作为导入模块。 Can I somehow link the library, so there is no actual source but a reference/link to it?我可以以某种方式链接图书馆,所以没有实际的来源,而是它的参考/链接?

Screenshot of how lib is added to project: lib如何添加到项目的屏幕截图:

添加如何将 lib 添加到项目的屏幕截图

PS: I used Project -> New-> Import Module with import option (first try I didn't have the import checkbox filled and the library was just empty) PS:我使用 Project -> New-> Import Module 和 import 选项(第一次尝试我没有填写导入复选框并且库只是空的)

There is no need for cloning the actual library or downloading it by yourself, you just need to import the library in the build.gradle file in your Android project like so:无需克隆实际库或自行下载,只需在 Android 项目中的build.gradle文件中导入库,如下所示:

dependencies {
    ...
    implementation "com.your.library:version.code"
    ...
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM