1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| 发布之前,要先把代码上传到github, 1️⃣ 准备 GitHub 仓库
整个项目已经上传到 GitHub,包括 app/ 和 mylibrary/ 模块。
确认 settings.gradle 包含 library:
include ':app', ':mylibrary'
确认 library 的 build.gradle 设置正确:
plugins { id 'com.android.library' id 'kotlin-android' }
android { namespace 'com.comm.library' compileSdk 36
defaultConfig { minSdk 24 consumerProguardFiles "consumer-rules.pro" } }
dependencies { implementation 'androidx.core:core-ktx:1.10.1' implementation 'androidx.appcompat:appcompat:1.6.1' api 'com.github.getActivity:XXPermissions:18.3' }
注意不要在 library 的 build.gradle 中添加 applicationId,它是 library 而不是 App。
2️⃣ 打 Tag(版本号)
在项目根目录执行命令:
git tag v1.0.0 git push origin v1.0.0
JitPack 会根据 Tag 构建版本。
3️⃣ 在 JitPack 上测试构建
打开 https://jitpack.io
在输入框输入你的仓库地址,例如:
https://github.com/mingname/androidcommonutils
点击 Look up → 选择 Tag(比如 v1.0.0) → 点击 Get it
JitPack 会给你 Gradle 依赖方式,例如:
dependencies { implementation 'com.github.mingname:androidcommonutils:v1.0.0' }
|