当前位置:   article > 正文

android repository github_android repositories github

android repositories 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'

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/311582
推荐阅读
相关标签
  

闽ICP备14008679号