Android上传library库到JitPack
2022-05-19 本文已影响0人
人世看客
一、背景
最近快离职了,闲的无聊,准备整理下属于自己的library库,想把自己的库放在网上去,用的时候直接依赖添加。首先想到的就是JitPack,于是网上查看了下资料,看怎么把我们的library发布到JitPack上去;配置的超顺利,下面记录下过程
二、项目配置
1.版本不同配置方法有些不同,本人用的是mac, Android studio是2021版的比较新,兼容到32。

3.配置mylibrary

代码片段:
plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
id 'maven-publish'
}
afterEvaluate {
publishing {
publications {
// Creates a Maven publication called "release".
release(MavenPublication) {
// Applies the component for the release build variant.
from components.release
// You can then customize attributes of the publication as shown below.
groupId = 'com.xiaoxing.test'
artifactId = 'chen'
version = '1.2.0'
}
}
}
}
4.创建github账号,把整个项目上传到自己的github上去,具体怎么把项目上传github省略
5.创建版本

Create a new release
按钮,下一步创建库版本号,填写相关信息

6.申请一个 JitPack账号,直接用github账号就行。然后进入此页面

注意:这里点击Get itbu界面直接下滑,没其它反应。可以再滑动回去,来回切换Release和Builds选项卡,Get it左边位置会出现转圈圈加载动画,等待加载完就好 7.成功后的用法,点击绿色的Get it按钮(也就是成功后的),页面会下滑

这里说明了使用方法
三、总结
此次配置相当顺利,没踩到坑,没啥好总结的。