简体   繁体   中英

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

I have a project with the following from 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:

在此处输入图片说明

The ABS is added as a dependency under Project Structure->module->Dependencies and the project builds correctly. Why do I not see ABS listed here? The IntelliJ IDEA context menu on External Dependencies is no help. 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. 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. It shouldn't do this; this bug: https://code.google.com/p/android/issues/detail?id=71106 is the request to change that.

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. 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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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