Android的工作室缺少的外部依赖性 [英] Android Studio missing external dependencies
问题描述
我有一个库项目。我想用Android的新版本系统。目前我遇到一个很烦人的场景。
I have a library project. I want to use Android's new build system. Currently I'm encountering a quite annoying scenario.
我对 gradle.build
定义我的依赖,但他们从来没有在Android Studio中外部库出现。因此,所有这些库中的引用标记为错误。
I have my dependencies defined on gradle.build
but they never appear under External Libraries in Android Studio. Hence all the references to those libraries are marked as errors.
当我在命令行中运行依赖的gradle
显示完整的依赖关系树,并成功编译。这个问题显然是与Android工作室。
When I run gradle dependencies
on the command line it shows the full dependencies tree and compiles successfully. The problem clearly is with Android Studio.
我试图重新启动IDE / OS,但一无所获。
I tried to restart the IDE/OS but nothing.
这是我的gradle.build
This is my gradle.build
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4.1'
}
}
apply plugin: 'android-library'
apply plugin: 'idea'
repositories {
mavenCentral()
}
dependencies {
compile 'junit:junit:4.11'
compile 'org.robolectric:robolectric:2.1:jar-with-dependencies'
compile 'com.google.android:android:4.1.1.4'
compile 'com.google.android:support-v4:r7'
compile 'info.cukes:cucumber-java:1.1.3'
compile 'info.cukes:cucumber-junit:1.1.3'
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
versionCode 1
versionName "0.3-SNAPSHOT"
minSdkVersion 15
targetSdkVersion 17
}
}
更新
此问题似乎固定在最新的Android Studio版本(0.2.5)
This issue seems to be fixed on latest Android Studio version (0.2.5)
推荐答案
不幸的是,Android Studio中的当前版本中,IDE没有完全与构建系统(gradle这个)集成在一起。你必须在 gradle.build
通过图形用户界面为code完成一次添加库进行编译,并一次。
Unfortunately, in the current version of Android Studio, the IDE is not completely integrated with the build system (gradle). You have to add the library once in gradle.build
for compilation, and once via the GUI for code completion.
右键点击您的项目,选择打开模块设置。确认警告。选择库,+,并添加您使用的图书馆。您可以搜索在出现的对话框中Maven的库。你应该选择你的库
DIR的罐子。最后,库添加到您的code的模块。如果您的应用MyApp的,你可能有MyApp的和MyAppProject。你需要将它添加到MyApp的。 (您可以大概也直接从模块页中添加它。)
Right click on your project, select "Open Module Settings". Acknowledge the warning. Select "Libraries", "+", and add the library you are using. You can search for libraries on Maven in the dialog that appears. You should select your libs
dir for the jar. Finally, add the library to your code's module. If your app is MyApp, you probably have MyApp and MyAppProject. You need to add it to MyApp. (You can probably also directly add it from the "Modules" page.)
要获得额外的gradle的jar添加到您的APK,进行以下修改你的成绩的文件。替换:
To additionally get gradle to add the jar to your apk, make the following changes to your grade file. Replace:
compile 'org.jsoup:jsoup:1.6.1'
和类似
compile files('libs/jsoup-1.6.1.jar')
现在它应该所有的工作。
Now it should all work.
这篇关于Android的工作室缺少的外部依赖性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!