Android Studio 使用第三方SDK经常会遇到直接从Maven 拉取 Jar 依赖包,如

Step1.1.1 配置maven仓库地址repositories {    maven { url 'http://repo.baichuan-android.taobao.com/content/groups/BaichuanRepositories/' }}Step1.1.2 依赖OpenIMSDKdependencies {    //必选    compile 'com.alibaba.mobileim:IMCore:2.0.1@aar'    //可选,如果使用SDK的UI必须添加该依赖,如果不使用SDK的UI,完全自己开发UI则无需添加该依赖    compile 'com.alibaba.mobileim:IMKit:2.0.1@aar'    //可选,如果使用小视频功能必须添加该依赖,如果不使用小视频功能则无需添加该依赖    compile 'com.alibaba.mobileim:RecorderSDK:1.0.0@aar'}

下面就为大家讲解如何在github上创建仓库,将jar和aar文件发布到maven中,以及如何集成。

先在要发布的Jar lib项目的 gradle 中添加如下配置


apply plugin: 'maven'   ext {    PUBLISH_GROUP_ID = 'cn.domob'    PUBLISH_ARTIFACT_ID = 'banneradtest'    PUBLISH_VERSION = '1.0'}uploadArchives {    repositories.mavenDeployer {        def deployPath = file(getProperty('localmavenpost'))        repository(url: "file://${deployPath.absolutePath}")        pom.project {            groupId project.PUBLISH_GROUP_ID            artifactId project.PUBLISH_ARTIFACT_ID            version project.PUBLISH_VERSION        }    }}

  def deployPath = file(getProperty('localmavenpost'))    
localmavenpost 为上传的文件名称, /Users/lang/maventest/test  为新创建的本地文件夹路径
在gradle.properties 中配置 localmavenpost=/Users/lang/maventest/test




点击 uploadArchives ,会生成需要的Jar 到/Users/lang/maventest/test目录下
在Github 创建一个工程,我命名的为newtest
然后命令行切换到 /Users/lang/maventest/test 目录,再把newtest 项目添加到 /Users/lang/maventest/test 目录下,git 命令如下
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/jia635/test.git
git push -u origin master




push 成功之后就是测试拉取项目
然后在最外层的build.gradle 中配置 
allprojects {
    repositories {
        jcenter()
        maven { url "https://raw.githubusercontent.com/jia635/newtest/master" }
    }
}
https://raw.githubusercontent.com/


这一部分是固定的,后面是我的项目名称
然后在需要引用Jar 的 项目的gradle  中进行引用

dependencies {    compile 'cn.domob:banneradtest:1.0'}


   
   
   
   


更多相关文章

  1. Android(安卓)升级到android studio 2.2项目死活run不起来
  2. AndroidStudio中的gradle脚本文件解读
  3. android实现文件下载功能
  4. React Native Android环境配置 第一个实例的坑
  5. android 9.0系统重启的代码详解
  6. android studio 导入eclipse项目 兼容性问题
  7. flutter集成推送功能-小米推送集成
  8. Android(安卓)Build System ---- how to add your product and b
  9. Android(安卓)强制下线功能 第一行代码

随机推荐

  1. 解决ListView或ExpandableListView滚动时
  2. android 设置对话框的宽度和高度
  3. android studio 中出现"...ProjectScript
  4. Android实现图片倒影效果
  5. Android之uri、file、path相互转化
  6. Android(安卓)Gradle Build Error:Some f
  7. Android(安卓)GPS NETWORK定位
  8. android 自定义线程,自动结束本身线程
  9. android FileNotFoundException错误:创建
  10. android实现状态栏添加图标的函数实例