android 仓库定位,Android Library 简单快速上传jcenter()仓库

1.什么是jcenter()

jcenter()是由bintray.com维护的maven仓库。

2.为什么选择jcenter()

jcenter()现在已经是android studio 默认的代码仓库,可以有效减少用户的操作。

buildscript {

repositories {

google()

jcenter()//这里,这里,看这里

}

dependencies {

classpath 'com.android.tools.build:gradle:3.1.3'

// NOTE: Do not place your application dependencies here; they belong

// in the individual module build.gradle files

}

}

3.注册账号

bf50cc3b55ef

image.png

bf50cc3b55ef

image.png

注意:部分邮箱验证不通过或者收不到邮件,亲测QQ邮箱不行,搜狐邮箱可以,其他邮箱大家可以尝试下。

4.创建Maven仓库

bf50cc3b55ef

image.png

bf50cc3b55ef

image.png

bf50cc3b55ef

image.png

5.在对应仓库中创建一个包

bf50cc3b55ef

image.png

bf50cc3b55ef

image.png

bf50cc3b55ef

image.png

6.创建一个Android Library (可选择略过)

1.创建Android Library

bf50cc3b55ef

image.png

bf50cc3b55ef

image.png

2.添加依赖

bf50cc3b55ef

image.png

3.增加测试代码

bf50cc3b55ef

image.png

4.测试引用

bf50cc3b55ef

image.png

7.配置build.gradle

为了方便,我们使用 bintray-release 来上传,根据github上面说明,一步步配置。

1.配置classpath,在最外层的build.gradle中

buildscript {

repositories {

google()

jcenter()

}

dependencies {

classpath 'com.android.tools.build:gradle:3.1.3'

classpath 'com.novoda:bintray-release:0.8.1'

// NOTE: Do not place your application dependencies here; they belong

// in the individual module build.gradle files

}

}

2.配置publish,在library的build.gradle中

apply plugin: 'com.novoda.bintray-release'

publish {

repoName = 'test'//远程仓库名字,不指明,默认是上传到maven

userOrg = '***'//bintray.com的用户名

groupId = 'com.test'//jcenter上的路径

artifactId = 'testlibrary'//项目名称

publishVersion = '0.0.1'//版本号

desc = 'for test'//描述

// website = "https://github.com/novoda/${rootProject.name}"//github 地址

}

8.运行下试试

bf50cc3b55ef

image.png

以上从github上拷贝,其中两个参数是未知的,一个是PbintrayUser ,还有个是PbintrayKey。PbintrayUser就是用户名,PbintrayKey是api key,在官网上可以获取到。

bf50cc3b55ef

image.png

bf50cc3b55ef

image.png

bf50cc3b55ef

image.png

bf50cc3b55ef

image.png

bf50cc3b55ef

image.png

publish中用户名那里把***换成真实的用户名。

bf50cc3b55ef

image.png

9.Add to jcenter

bf50cc3b55ef

image.png

bf50cc3b55ef

image.png

10.测试

bf50cc3b55ef

image.png

bf50cc3b55ef

image.png

完美打印包中的日志,测试成功。

11.遇到的坑

HTTP/1.1 400 Bad Request

* What went wrong:

Execution failed for task ':mylibrary:bintrayUpload'.

> Could not create package 'theangrybear/test/testlibrary': HTTP/1.1 400 Bad Request [message:Please enter a valid VCS URL for your package.]

解决方案:没有创建对应的包,也就是缺少上述的第5步。

缺少Pom文件,没有自动生成

关于将android项目发布到jcenter的最新最全说明 参考问题3

bf50cc3b55ef

image.png

bf50cc3b55ef

image.png

bf50cc3b55ef

image.png

解决方案:

1.生成pom文件

执行 ./gradlew clean build 命令

bf50cc3b55ef

image.png

2.上传

执行 ./gradlew bintrayUpload -PbintrayUser=用户名 -PbintrayKey=Api key -PdryRun=false

不要再clean,防止pom文件被清掉

bf50cc3b55ef

image.png

注释出现编码等错误

//添加

tasks.withType(Javadoc) {

options.addStringOption('Xdoclint:none', '-quiet')

options.addStringOption('encoding', 'UTF-8')

options.addStringOption('charSet', 'UTF-8')

}

使用Bintray 上传包到Jcenter上报错

Failed to send a message: The version control 0.0.1 returns 404.

bf50cc3b55ef

image.png

1.复制如下地址,后面有用

bf50cc3b55ef

image.png

2.编辑

bf50cc3b55ef

image.png

3.更新

bf50cc3b55ef

image.png

4.点击Add to JCenter 即可成功

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值