如何在IntelliJ IDEA中添加外部库? [英] How to add external library in IntelliJ IDEA?
问题描述
我正在尝试将外部库(放在/ libs目录中)添加到我的项目中。当我尝试使用该库中的方法时,我发现它们是红色的,这意味着无法识别该库。当我单击Ctrl + B时,我收到一条消息无法找到要转到的声明。
I am trying to add external library (places it in the /libs directory) to my project. When I try to use the methods from that library, I see that they are in red color which means that the library is not recognized. When I click Ctrl+B, I get a message "Cannot find declaration to go to".
我使用这些步骤添加库(JAR文件):
1.将库文件复制到/ libs dir
2.打开项目结构 - >全局库 - >附加clases
3.找到库并单击确定
I use these steps to add a library (JAR file): 1. copy the library file into /libs dir 2. open Project Structure -> Global Libraries -> Attach clases 3. find the library and click ok
这是正确的方法吗?
PS。我试图以这种方式添加AdMob .jar文件。
PS. I am trying to add AdMob .jar file this way.
推荐答案
最新版本的程序更简单:
Easier procedure on latest versions:
- 将jar复制到应用程序中的libs目录(如果不存在,可以创建目录)
- 刷新项目,使libs显示在结构中(右键单击项目顶层,刷新/同步)
- 展开库并右键单击jar
- 选择添加为库
- Copy jar to libs directory in the app (you can create the directory it if not there)
- Refresh project so libs show up in the structure (right click on project top level, refresh/synchronize)
- Expand libs and right click on the jar
- Select "Add as Library"
完成
这篇关于如何在IntelliJ IDEA中添加外部库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!