如何在Android的工作室/的IntelliJ导入Maven的依赖? [英] How to import Maven dependency in Android Studio/IntelliJ?

查看:136
本文介绍了如何在Android的工作室/的IntelliJ导入Maven的依赖?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了使用Android的Studio中的默认的向导一个新的Andr​​oid项目。编译和部署应用程序到我的设备。一切都很好。

I've created a new Android project using the default wizard in Android Studio. Compiled, and deployed the app to my device. All is well.

现在我想导入外部库上可用的Maven。 ( http://square.github.io/picasso/ )。我去了模块性能,并增加一个Maven库。它正确地显示在依赖项列表。此外,它显示在编辑器中,我可以正确地使用它在code。

Now I want to import an external library that is available on Maven. (http://square.github.io/picasso/). I went to module properties, and added a Maven library. It shows up correctly in the list of dependencies. In addition, it shows up in the editor and I can correctly use it in code.

不过,在编译时,我得到一个摇篮错误: 无法找到类

However, at compile time, I get a Gradle error: unable to find class

任何想法?

推荐答案

随着0.8.9版本,Android的工作室默认支持Maven的中央仓库。所以要加一个外部的Maven的依赖,所有你需要做的是编辑模块的build.gradle文件,并将行成这样的依赖性部分:

As of version 0.8.9, Android Studio supports the Maven Central Repository by default. So to add an external maven dependency all you need to do is edit the module's build.gradle file and insert a line into the dependencies section like this:

dependencies {

    // Remote binary dependency
    compile 'net.schmizz:sshj:0.10.0'

}

您将看到一条消息出现像立即同步... - 单击它并等待Maven的回购将连同其所有相关下载。将有在状态栏中的一些消息在底部告诉你发生了什么就下载。之后它完成这一点,连同其依赖进口的JAR文件将被列在项目浏览器窗口中的外部存储库树,如下图所示。

You will see a message appear like 'Sync now...' - click it and wait for the maven repo to be downloaded along with all of its dependencies. There will be some messages in the status bar at the bottom telling you what's happening regarding the download. After it finishes this, the imported JAR file along with its dependencies will be listed in the External Repositories tree in the Project Browser window, as shown below.

一些进一步的解释,在这里: <一href="http://developer.android.com/sdk/installing/studio-build.html">http://developer.android.com/sdk/installing/studio-build.html

Some further explanations here: http://developer.android.com/sdk/installing/studio-build.html

这篇关于如何在Android的工作室/的IntelliJ导入Maven的依赖?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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