Android使用gradle生成maven库,上传githu并使用远程maven库
整个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'}
更多相关文章
- Android Studio-Gradle项目中添加JNI生成文件(.so文件)
- Android 一个APK文件部署产生多个应用安装的效果
- Android 资源文件中的符号含义与说明
- [zz http://www.cnblogs.com/oldfeel/archive/2012/05/15/250129
- android -上传文件到服务器
- Android中使用XmlPullParse解析xml文件
- 如何将library项目打包成jar文件
- How to decompile .dex file on Android如何反编译.dex文件