整个demo 项目github https://github.com/lihonghao1017/andoridHotFix
maven地址https://github.com/lihonghao1017/HotFixAndroidMaven
1,创建一个Androidstudio 项目
注意 apply plugin: 'com.android.library' 不能是application; applicationId ‘报名’也注释掉
需要 apply plugin : 'maven'
2,创建生成maven文件Task
uploadArchives{
repositories.mavenDeployer {
def mavenRepositoryPath = file(getProperty('aar.hotfix'))//aar.hotfix定义在gradle.properties,为生成maven目录
repository(url: "file://${mavenRepositoryPath.absolutePath}")
pom.project{
groupId "com.lihh.hotfix"
artifactId "hotfix"
version 1.1
}
}
}
gradle.property
3,生成maven文件 打开gradle任务管理器 app->upload->uploadArchives 点击uploadArchives 生成maven文件
4,在github上创建maven工程,clone到桌面mavenFirst文件夹, 将生成的maven 文件提交到github
5使用 我的maven地址为https://github.com/lihonghao1017/HotFixAndroidMaven
通过maven 访问 需要将github.com改为raw.githubusercontent.com;即https://raw.githubusercontent.com/lihonghao1017/HotFixAndroidMaven
GitHub的raw.githubusercontent.com无法链接
修改Hosts临时解决GitHub的raw.githubusercontent.com无法链接
通过IPAddress.com首页,输入raw.githubusercontent.com查询到真实IP地址
199.232.28.133
C:\Windows\System32\drivers\etc
hosts文件
添加 以下内容并保存即可恢复
199.232.28.133 raw.githubusercontent.com
6. 使用项目加入依赖
repositories{
jcenter()
maven {
url "https://raw.githubusercontent.com/lihonghao1017/HotFixAndroidMaven/master"
}
}
dependencies {
implementation 'com.lihh.hotfix:hotfix:1.0'
}