Warning about an Android Library project gradle dependencies

眉间皱痕 提交于 2019-12-25 04:17:44

问题


I am building an Android Library project using Android Studio. The type of the module is 'com.android.library' in gradle.build file. This module has a number of dependencies:

dependencies {    
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'com.squareup.okhttp:okhttp:2.3.0'
}

The module builds result in a .aar file. I want the user of the .aar file to be notified/warned about .aar dependencies so his project doesn't successfully builds till these dependencies are set inside his project. Is there a way to do this?


回答1:


I want the user of the .aar file to be notified/warned about .aar dependencies so his project doesn't successfully builds till these dependencies are set inside his project.

Well, to some extent, that would happen automatically, as their compile would fail.

If you distribute this AAR as an artifact in a repository, the repository metadata (e.g., POM file for a Maven repo) can contain information about these dependencies. Many build systems (Gradle, Maven, etc.) will use that to automatically download those dependencies as needed when the developer uses your artifact.

If you elect to distribute this AAR by other means (e.g., a QR code the size of a small mountain), you will need to tell developers that they need to include these dependencies through documentation of some sort.

Anticipating a follow-up question...

I should be able to publish a .aar closed source artifact through a Maven repo ?

Sure. While Maven Central and JCenter are tailored for open source, you can certainly have your own repo. It's just a directory with certain contents. For example, I have my own repo for my open source libraries, and while my libraries are open source, there is nothing about the repo that would require the repositories to hold open source code.



来源:https://stackoverflow.com/questions/30202718/warning-about-an-android-library-project-gradle-dependencies

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!