如何在 IntelliJ IDEA 中添加外部库? [英] How to add external library in IntelliJ IDEA?

查看:396
本文介绍了如何在 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目录2.打开项目结构->全局库->附加类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

这是正确的做法吗?

附注.我正在尝试以这种方式添加 AdMob .jar 文件.

PS. I am trying to add AdMob .jar file this way.

推荐答案

在最新版本上更简单的程序:

Easier procedure on latest versions:

  • 将 jar 复制到应用程序中的 libs 目录(如果没有,您可以创建它的目录)
  • 刷新项目,使库显示在结构中(右键单击项目顶层,刷新/同步)
  • 展开库并右键单击 jar
  • 选择添加为库"

完成

这篇关于如何在 IntelliJ IDEA 中添加外部库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆