指定在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.