Android发布项目到github
一、注册GitHub账号:https://github.com
二、android studio 创建新的项目:
三、创建Module
操作步骤
① 点击顶部 File
② 点击 New
③ New Module
找不到的可以参考下图 ☟ --↓:
④选择Android Library
⑤ 输入你的库名等 点击Next
⑥ 在项目的build.gradle 的
buildscript { repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.6.1' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' // 添加这行配置 1.5是根据我的gradle的版本来的 实际是需要看你的gradle版本而定 如果是4.0+ 就是2.0了 // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() jcenter() } }
打开Module根目录下的Gradle加入两行代码:
apply plugin: 'com.github.dcendents.android-maven'
group='com.github.zhangchengkun12'
group后面的是Github上的域名 zhangchengkun12 是我的github账户名 你需要换成自己的域名
apply plugin: 'com.android.application' apply plugin: 'com.github.dcendents.android-maven'//这里是需要加入的 第一行 总共2行 group = 'com.github.zhangchengkun12'//这里是需要加入的 第二行 总共2行 android { compileSdkVersion 29 buildToolsVersion "29.0.3" defaultConfig { applicationId "zxt.github" minSdkVersion 23 targetSdkVersion 29 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'androidx.appcompat:appcompat:1.1.0' }
四、上传项目到Github
首先装上Git,然后验证一下
然后如下图选择分享项目到Github
输入账号密码
自行选择项目名称和分支标签和描述
点击Share
进入GitHub,查看是否上传成功。
点击进入项目
点击releases
创建release
填入版本号,然后点击Publish release
五、将GitHub项目上传到https://jitpack.io/ ,将GitHub项目链接复制到输入框。点击Look up
Get it
根据提示,在项目中导入implementation包,如图,导入成功
前提在项目的build.grade 里面添加maven { url 'https://jitpack.io'}
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 | // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { google() jcenter() maven { url 'https://jitpack.io' } } dependencies { classpath 'com.android.tools.build:gradle:3.2.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() jcenter() maven { url 'https://jitpack.io' } } } |
在modle 的build.gradle 里面导入依赖
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 | apply plugin: 'com.android.application' android { compileSdkVersion 28 defaultConfig { applicationId "com.why.project.hwpushdemo" minSdkVersion 16 targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile( 'proguard-android.txt' ), 'proguard-rules.pro' } } } dependencies { implementation fileTree(dir: 'libs' , include: [ '*.jar' ]) implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.github.zhangchengkun12:MyAndroidTool:v1.0' } |
本人记录一下操作流程 是学习一粒代码写的文档做的。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通