前言
在开发过程中,会使用到很多第三方开源库,比如imageloader,zxing,或者一个baseadapter,一个工具库等等。。AndroidStudio中集成时候只要一句话 compile 'com.github.superSp:ScrollChooseView:v1.0.2
(举个例子), 一般像这种的都是将你的module上传到jcenter之后审核就可以了。。。。如果想做一个优秀的android开发者,在经验慢慢积累后也应该有自己的优秀开源库上传到github给他人使用,毕竟面试的话如果你的github某个开源库start数很多的话也是一张强大的手牌。
Jcenter的方式
研究jcenter的方式整整一天了。。。最后一个步骤 add to jcenter的按钮找不到。。。而且网站打开速度也比较慢。。就放弃了,后来在群里面听说有还有一种方式叫jitpack
。。就百度看了一下感觉更简单。。。这里先贴一下Jcenter方式的链接
鸿洋大神Jcenter博客,但是好像有一个小坑,点击
解决鸿洋大神Jcenter博客中的坑。。。点击
有这两篇文章就差不多OK拉。。。
JitPack方式
创建一个project

创建一个lib

在根projcet的build.gradle中添加
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
maven { url 'https://jitpack.io' }

在lib目录下build.gradle中添加
apply plugin: 'com.github.dcendents.android-maven' group = 'com.github.superSp'
黄色圈修改为自己的github名

上传到github
打开github创建新的仓库,输入仓库名,仓库描述


创建成功以后,红色框列出本地仓库上传到github的步骤

打开Git Bash

到当前项目的目录下
依次输入
git init ---------初始化仓库
git add . ---------- .表示的是上传当前整个目录
git commit -m "first commit" ------------- 提交的描述
git remote add origin git@github.com:superSp/Test.git ----------- 添加到远程库
git push -u origin master --------------提交远程库
在上传成功以后,生成一个release版本


之后打开jitpack网站
地址
输入库的名字,点击look up

点击get it

熟悉的使用方式就出现了

注意
第一次上传项目到github时,要匹配私钥,不懂的话看这里这是一篇介绍git的使用方式以及上传连接github的操作
网友评论