android repository github

使用github作为远程仓库repository,封装功能模块。之后,通过gradle dependency方式集成,方便调用。

1.github repository

登录github->new repository,作为maven仓库,得到远程地址,如:https://github.com/FreeLeo/AAR.git

2.安装git工具

下载地址:https://git-scm.com/downloads

选择一个文件夹,作为本地的repository,与github关联

使用【Git Bash Here】关联

git init 

git add .

git clone https://github.com/FreeLeo/AAR.git


3.library

使用Android studio,建立Moudle.

build.gradle 中修改如下部分:

apply plugin: 'com.android.library'
apply plugin: 'maven'
uploadArchives {
    repositories.mavenDeployer {
        def mavenRepositoryPath = file(getProperty('aar.Utils'))
        repository(url: "file://${mavenRepositoryPath.absolutePath}")
        pom.project {
            groupId "com.android.open.utils"
            artifactId "Utils"
            version 1.0
        }
    }


Project Properties gradle.properties修改

aar.Utils=D:\\aar\\AAR

4.编译生成aar

使用命令:gradlew uploadArchives 

若编译成功,会在配置的本地repository中生成。


5.git上传到github

将未缓存的改动添加到已缓存的活动;

提交

上传

之后到github确认是否上传成功。


6.远程依赖

6.1 复制git当前界面地址,并修改,添加到根目录build.gradle中,位置如下:

即 github.com ——> raw.githubusercontent.com
再在末尾追加/master
表示当前要选用的是master分支的内容

如https://github.com/FreeLeo/AAR 修改为https://raw.githubusercontent.com/FreeLeo/AAR/master

allprojects {
    repositories {
        jcenter()
        maven { url "https://raw.githubusercontent.com/FreeLeo/AAR/master"}
    }
}

6.2 在需要引用的module的build.gradle  dependencies中添加:

compile 'com.android.open.utils:Utils:1.0'

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值