您的位置:首页 > 移动开发 > Android开发

Android之发布项目至jcenter

2016-08-09 07:27 316 查看
本文主要记录一些零碎的东西

这篇文章中的项目发布到仓库,这个我也是头一次,查了好些,但是好多人的都说不清楚,反正作为一个新手的我看着挺乱

整理整理流程:

1 .先去注册一个账户:https://bintray.com (jcenter的代码仓库),我选的第三方登录

2. 登录后啥都不需要做,找了一个配置特别简单的类库 

novoda/bintray-release : https://github.com/novoda/bintray-release

3. 找一下自己的key,点击用户名进去就可以看见,后面需要用到



4.回到Android Studio,项目的build.gradle文件(不是module的),新增

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
// upload jcenter needs
classpath 'com.novoda:bintray-release:0.3.4'
}
}


要上传的module的build.gradle文件

apply plugin: 'com.android.library'
apply plugin: 'com.novoda.bintray-release'//添加
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"

defaultConfig {
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.0.0'
}

//添加
publish {
userOrg = 'cl-window'//bintray.com用户名
groupId = 'com.cl.slack'//jcenter上的路径,一般填你唯一的包名
artifactId = 'progressbar'//项目名称
publishVersion = '1.0.0'//版本号
desc = 'progressbar segment color'//描述,不重要
website = 'https://github.com/CL-window/progressBar'//网站,不重要;尽量模拟github上的地址
}


点击底部的Terminal即可输入命令来上传

windows:
gradlew clean build bintrayUpload
-PbintrayUser=cl-window
-PbintrayKey=**********...*****

mac / linux :
./gradlew clean build bintrayUpload
-PbintrayUser=cl-window
-PbintrayKey=**********...*****
-PdryRun=false

user就是用户名,key就是我们刚才的让你保存的key,dryRun是一个配置参数,当为true的时候,会运行所有的环节,但是不会上传。

我的注释是使用的中文,上传是报错了,编码不一样,一个GBK,一个UTF8,没有找到好的方案解决,删注释咯



然后重新上传,成功后回到网站上,等一会儿刷新一下,会发现出来项目了,默认在maven仓库下



接下来就是添加到jCenter,点击你的项目进去,如我的 progressbar,然后一个按钮就好





随便填一下,就等那边审核通过吧,过了会发邮件提示,时间不一定,至少一个小时,通过了会给你邮件提醒
成功后



成功后在需要的项目里的build.gradle  文件里dependencies添加依赖就可以使用了



是不是看着就特别简单,主要是前人都给我们做好了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  jCenter