AndroidStudio上传Library到JCenter

本文不做过多描述,以我个人的utils library上传为例,直接列举操作步骤:

注册bintray账号

网址:https://bintray.com/signup/oss

注:可通过GithubGoogleTwitter授权bintray实现注册

创建bintray仓库

网址:https://bintray.com/profile/edit

操作步骤:

  1. 点击左侧“Repositories”选项,
  2. 点击该选项右侧“New Repository”按钮,
  3. 填写Name选项框的值为“maven”,
  4. 选择Type选项框的值为“Maven”,
  5. 点击“Create”按钮。

注意:Name选项框的值maven必须是小写。

配置gradle参数

配置Project的build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files

        classpath 'com.novoda:bintray-release:0.3.4' // 新增
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

配置Library项目的build.gradle

apply plugin: 'com.android.library'
apply plugin: 'com.novoda.bintray-release' // 新增

android {
    ...
}

dependencies {
    ...
}

publish { // 新增
    userOrg = 'fqxyi' // 注册bintray时的username
    groupId = 'com.fqxyi.utils' // 项目包名
    artifactId = 'utils' // 项目名
    publishVersion = '1.0.0' // 发布版本号
    desc = 'Summarize the tools or methods commonly used in routine development' // 项目描述,可选项
    website = 'https://github.com/fengqingxiuyi/AndroidUtils' // 项目站点,可选项
}

执行上传命令

命令:

./gradlew clean build bintrayUpload -PbintrayUser=username -PbintrayKey=API Key -PdryRun=false

命令解释:

  1. PbintrayUser的值为注册bintray时的username,
  2. PbintrayKey的值为bintray的Api Key,可从https://bintray.com/profile/edit网址左侧的API Key选项中得到,
  3. PdryRun是一个配置参数,当为true时,表示会运行所有环节,但不会上传。–该句摘自网络,尚未理解

申请添加到JCenter

网址:https://bintray.com/username/maven/artifactId

注意:

  1. 网址中的username需要更换为注册bintray时的username,
  2. 网址中的artifactId需要更换为项目名。

操作步骤:

  1. 点击右下角的“Add to jcenter”按钮添加library package到jcenter,会跳转到https://bintray.com/message/addPackageToJCenter?pkgPath=/fqxyi/maven/utils网址,
  2. 点击“Send”按钮发送请求。

检测是否申请通过

访问https://jcenter.bintray.com/groupId/artifactId/publishVersion网址,如果能看到以下四个文件即表示申请通过:

artifactId-publishVersion-javadoc.jar
artifactId-publishVersion-sources.jar
artifactId-publishVersion.aar
artifactId-publishVersion.pom

注意:网址中的groupId,默认是项目包名,在其成为网址的一部分后,需要将.符号改为/符号,例如:https://jcenter.bintray.com/com/fqxyi/utils/utils/1.0.0/

FAQ

Repo ‘maven’ was not found

问题:

* What went wrong:
Execution failed for task ':androidutilslibrary:bintrayUpload'.
        > Could not create package 'fqxyi/maven/androidutilslibrary': HTTP/1.1 404 Not Found [message:Repo 'maven' was not found]

解决:未创建仓库 或 仓库名写错,注意maven是小写

Lint检查报错

问题:Lint检查报错,导致Build & Upload失败

解决:

方式一:需要自行根据错误信息修正Error级别的问题,

方式二:为Library项目的build.gradle配置以下Lint选项实现,–该方式摘自网络,未验证

android {

    ...

    lintOptions {
        abortOnError false // 即使有报错也不会停止打包
        checkReleaseBuilds false // 打包Release版本的时候也不进行Lint检测
    }

    ...

}

网络问题导致的上传失败

问题:

* What went wrong:
Execution failed for task ':utils:bintrayUpload'.
> javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
* What went wrong:
Execution failed for task ':utils:bintrayUpload'.
> org.apache.http.conn.HttpHostConnectException: Connection to http://127.0.0.1:8888 refused
* What went wrong:
Execution failed for task ':utils:bintrayUpload'.
> org.apache.http.NoHttpResponseException: The target server failed to respond

解决:

步骤1:关闭代理软件,重启网络;

步骤2:关闭由上传操作自动开启的Java客户端(Mac上会出现,其他设备不清楚)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值