简体   繁体   English

是什么决定了IntelliJ IDEA / Android Studio中填充“外部依赖项”的原因?

[英]What determines what populates “External Dependencies” in IntelliJ IDEA/Android Studio?

I have a project with the following from build.gradle : 我有一个来自build.gradle的项目:

dependencies {
    compile 'com.actionbarsherlock:actionbarsherlock:4.4.0@aar'
    compile 'com.android.support:support-v4:+'
}

And yet Project->External Dependencies only show the SDK, the JDK, and the support library: 但是Project-> External Dependencies仅显示SDK,JDK和支持库:

在此处输入图片说明

The ABS is added as a dependency under Project Structure->module->Dependencies and the project builds correctly. 将ABS作为依赖项添加到“项目结构”->“模块”->“依赖项”下,项目将正确构建。 Why do I not see ABS listed here? 为什么我看不到此处列出的ABS? The IntelliJ IDEA context menu on External Dependencies is no help. External Dependencies上的IntelliJ IDEA上下文菜单没有帮助。 Is this a bug? 这是错误吗? Does it matter? 有关系吗?

It depends on whether you specify the packaging type (eg @aar ) in the Maven coordinates for the dependency or not. 这取决于您是否在Maven坐标中为依赖项指定打包类型(例如@aar )。 If you don't, then the library and its dependencies show up in the External Dependencies view. 如果不这样做,那么库及其依赖项将显示在“外部依赖项”视图中。 I'd recommend omitting it. 我建议省略它。

Android Studio tends to add the packaging type, at least for dependencies that you add via the search function in Project Structure > Dependencies. Android Studio倾向于添加打包类型,至少对于通过“项目结构”>“依赖关系”中的搜索功能添加的依赖关系而言。 It shouldn't do this; 它不应该这样做; this bug: https://code.google.com/p/android/issues/detail?id=71106 is the request to change that. 此错误: https : //code.google.com/p/android/issues/detail?id=71106是更改请求。

Gradle doesn't follow transitive dependencies for libraries you include the packaging for, so this is actually harmful unless you know you need to use it. 对于包含了包装的库,Gradle不会遵循传递依赖关系,因此,除非您知道需要使用它,否则这实际上是有害的。 It's this behavior that could be causing libraries to not show up in the External Libraries view (though the fact that it not only doesn't show transitive dependencies but the actual library itself doesn't really mesh with that idea). 正是这种行为可能导致库没有出现在“外部库”视图中(尽管它不仅不显示可传递的依赖关系,而且实际的库本身并不真正与该想法保持一致)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM