如何发布,可以很容易被其他人工作中导入的android库? [英] How does publishing android libraries that can be imported easily by other people work?

查看:179
本文介绍了如何发布,可以很容易被其他人工作中导入的android库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可以很容易地使用第三方库,摇篮。例如,下面允许我使用改造我的应用程序。

It is possible to easily use third party libraries with gradle. For example, the following allows me to use Retrofit in my app.

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

这是如何工作的?哪里图书馆从何而来?总体而言,我怎么会去发布一个库,以便其他人可以导入像这样?

How does this work? Where does the library come from? In general terms, how would I go about publishing a library so that other people can import it like this?

请注意:这不是发布的jar库用来bintray摇篮 <一href="http://stackoverflow.com/questions/27153034/publish-jar-library-to-bintray-using-gradle">/publish-jar-library-to-bintray-using-gradle.这个问题是问spefic问题关于一个特定的方式来发布库。

Note: this is not a duplicate of Publish jar library to bintray using gradle/publish-jar-library-to-bintray-using-gradle. That question was asking a spefic question about one particular way to publish libraries.

推荐答案

很多这本的教程

这是如何工作的?

摇篮导入库从一个仓库。 Maven仓库可以同时包含普通.jar文件和定期.aar文件。

Gradle imports the libraries from a Maven repository. The Maven repository can contain both regular .jar files and regular .aar files.

在什么地方图书馆从何而来?

Where does the library come from?

在默认情况下,Android的工作室进口从JCenter的新版本。 JCenter是Maven仓库由公司Bintray运行。

By default, new versions of Android Studio import from JCenter. JCenter is a Maven Repository run by the company Bintray.

如果你看一下你的Andr​​oid Studio项目的 build.gradle ,你会看到下面的行

If you look at your Android Studio project's build.gradle, you'll see the following lines

repositories {
    jcenter()
}

这告诉摇篮它应该尝试导入时, com.squareup.retrofit:改造:1.9.0

This tells gradle where it should look when attempting to import com.squareup.retrofit:retrofit:1.9.0.

在总体而言,我将如何去有关发布库,以便其他人可以导入像这样?

In general terms, how would I go about publishing a library so that other people can import it like this?

您需要以上传到JCenter因为Bintray拥有JCenter创建Bintray帐户。 Bintray的网站是pretty的易于使用的相比有什么Maven的中央,在过去的默认Maven仓库使用Android的工作室。

You need to create a Bintray account in order to upload to JCenter since Bintray owns JCenter. Bintray's website is pretty easy to use compared to what Maven Central, the past default Maven Repository used by Android Studio.

您已经创建了里面的Andr​​oid Studio中的一个正常的库模块后,你需要手工调整你的库模块的 build.gradle 文件,以便将其配置为Maven的。最后,您可以使用pre出炉的脚本,一切都上传到Bintray。

After you've created a normal Library module inside Android Studio, you'll need to hand tweak your library module's build.gradle file in order to configure it for Maven. Finally, you use a pre-baked script to upload everything to Bintray.

这篇关于如何发布,可以很容易被其他人工作中导入的android库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆