指定在build.gradle Maven的依赖关系不工作 [英] Specifying Maven dependencies in build.gradle doesn't work

查看:334
本文介绍了指定在build.gradle Maven的依赖关系不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想一个Maven依赖关系添加到我的项目,它采用摇篮,通过将这些线在Android的Studio中build.gradle文件:

I tried to add a Maven dependency to my project, which uses Gradle, by adding these lines to the build.gradle file in Android Studio:

repositories {
    mavenCentral()
}

dependencies {
    compile files('libs/android-support-v4.jar')
    compile 'org.roboguice:roboguice:2.0'
}

该项目似乎编译好了,但没有办法引用Roboguice类中我的项目的code。我觉得我失去了一些东西,即如何摇篮下载的依赖,并在那里将其存储呢?我应该如何解决我的项目?

The project seems to compile well, but there's no way to reference Roboguice classes inside my project's code. I feel like I'm missing something, namely, how does Gradle download the dependency and where will it store it? How should I fix my project?

推荐答案

使用命令行,在你的项目中,运行的根源:
./ gradlew清洁和放大器;&安培; ./gradlew建

Using the command line, in the root of your project, run :
./gradlew clean && ./gradlew build

然后重新编译您的项目在工作室,你应该看到您的新的依赖。

Then recompile your project in studio and you should see your new dependencies.

编辑:在回答的时候,Android的工作室没有提出的摇篮同步按钮。现在呢,因此而不是使用命令行,你可以按下按钮,它会基本上运行 ./ gradlew清洁和放大器;&安培; ./gradlew建给你。

At the time of the answer, Android studio didn't propose the "Gradle sync" button. It now does, so rather than using the command line, you can hit the button, and it will basically run ./gradlew clean && ./gradlew build for you.

不管怎么说,这是一件好事,知道怎么做,在命令行:)

Anyway, it's always good to know how to do it in command line :)

按钮的名称为:同步工程与摇篮文件
请参见下面的截图。

The name of the button is: Sync Project with Gradle Files
See the screenshot below.

这篇关于指定在build.gradle Maven的依赖关系不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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