美文网首页
使用android studio上传android项目到JCen

使用android studio上传android项目到JCen

作者: potenstop | 来源:发表于2018-08-11 20:16 被阅读0次

    环境

    android studio 3.1
    jdk 1.8

    1 注册bintray账号

    注册地址: https://bintray.com/signup/oss

    image.png

    注意邮箱需要填gmail的邮箱

    2 在bintray上新建组织

    在上传的配置中需要填写上传项目对应的组织


    image.png image.png
    image.png

    3 创建maven仓库

    回到首页 在面板上找到add new repostory


    image.png
    image.png

    4 创建package

    image.png image.png

    5 获取api key

    image.png
    image.png image.png

    6 增加编译的插件

    在项目(project:xxx)的build.gradle中buildscript中添加如下脚本

    buildscript {
        repositories {
            jcenter()
        }
        dependencies {
            classpath 'com.novoda:bintray-release:0.8.1'
        }
    }
    

    7 在上传的module的build.gradle中如下增加:

    apply plugin: 'com.novoda.bintray-release'
    publish {
        userOrg = 'ptchat' //bintray账户下某个组织id 第2步创建的组织id
        groupId = 'top.potens.ptchat' //maven仓库下库的包名,一般为模块包名
        artifactId = 'ptchat-android' //项目名称
        publishVersion = '1.0.0' //版本号
        desc = 'ptchat for android' //项目介绍
        website = '' //项目主页
    }
    tasks.withType(JavaCompile) {
        options.encoding = "UTF-8"
    }
    tasks.withType(Javadoc) {
        options.encoding = "UTF-8"
    }
    
    

    8 上传项目到jcenter

    使用android studio 的terminal执行
    PbintrayUser: 第1步注册的用户名
    PbintrayKey: 第5步获取的api key
    clean build: 清除上一次的build
    PdryRun: true: 不上传到jcenter ,false: 上传到jcenter

    gradlew clean build bintrayUpload -PbintrayUser={user} -PbintrayKey={api key} -PdryRun=false
    

    返回如下则上传成功


    image.png

    9 在bintray查看项目

    地址为: https://bintray.com/{组织id}/{repostory name}/{package name},如本项目的地址为:
    https://bintray.com/ptchat/maven/ptchat-android

    image.png

    10 项目添加到jcenter

    项目首页->add jcenter


    image.png
    image.png

    11 错误

    在执行gradlew 进行项目上传时候,出现: 错误: 编码GBK的不可映射,则需要配置JavaCompile和JavaDoc的encoding,也就是第7步。因为编译时使用的GBK编码,项目设置的为utf-8,所以中文的注释或者代码在lint检查时候就会报错。

    相关文章

      网友评论

          本文标题:使用android studio上传android项目到JCen

          本文链接:https://www.haomeiwen.com/subject/hpdypftx.html