在jitpack创建Android仓库

Android Studio创建远程仓库

    将Android代码托管到GitHub上后,可通过JitPack创建一个远程的Android依赖库,通过compile ‘……’即可使用,看一下具体步骤。
    首先打开Android Studio创建一个Android工程,选择工程右键选择new -> modle选择==Android Library==点击下一步即可,如下图:

创建安卓仓库创建安卓仓库

然后在工程的build.gradle下添加如下代码:

 dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }

在library的build.gradle配置github账户信息:

apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
group='com.github.YourName'

配置玩点击Sync Now即可。

使用本地库,在工程中创建本地依赖:

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support:support-v4:26.1.0'
    implementation 'com.android.support:recyclerview-v7:26.1.0'
    implementation 'com.android.support:design:26.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation project(':mylibrary')
}

这样就可以调用mylibrary库中的类和方法了,当然也可以调用xml资源和图片。
到这里本地库就创建完成了,现在把它托管到Github,如下图,是我托管后的项目
这里写图片描述
托管完成后点击release,添加版本号、版本名、简要说明:
这里写图片描述
版本发布后:
这里写图片描述
发布后复制项目地址:
这里写图片描述
打开JitPack官网,输入复制的设置,点击Look up,选择发布的版本,点击Get it即建立远程仓库:
这里写图片描述
这里写图片描述
使用的时候和正常的依赖库用法一样,这里就不多说了。


参考网站:
https://developer.android.com/studio/projects/android-library.html?hl=zh-cn
https://developer.android.com/studio/build/dependencies.html#remote-repositories

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值