Android Studio创建远程仓库

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

在jitpack创建Android仓库_第1张图片在jitpack创建Android仓库_第2张图片

然后在工程的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,如下图,是我托管后的项目
在jitpack创建Android仓库_第3张图片
托管完成后点击release,添加版本号、版本名、简要说明:
在jitpack创建Android仓库_第4张图片
版本发布后:
在jitpack创建Android仓库_第5张图片
发布后复制项目地址:
在jitpack创建Android仓库_第6张图片
打开JitPack官网,输入复制的设置,点击Look up,选择发布的版本,点击Get it即建立远程仓库:
在jitpack创建Android仓库_第7张图片
在jitpack创建Android仓库_第8张图片
使用的时候和正常的依赖库用法一样,这里就不多说了。


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

更多相关文章

  1. 利用AS(3.0)工具将工程打包成jar
  2. Android快速开发框架之xUtils---图片模块
  3. Android ImageView图片自适应大小
  4. android切换到后台图片纹理丢失的解决方案
  5. 万能imageLoader加载图片的包装,直接用
  6. 导入android工程出现:unable to get system library for the proj
  7. 2010.12.16——— android listView 显示图片 内存溢出问题
  8. [置顶] 我的Android进阶之旅------>android异步加载图片显示,并且

随机推荐

  1. android 加载动态库
  2. Android 中文api (88)――SharedPreferen
  3. Android(安卓)Model正确使用姿势——Auto
  4. android中调用接口发送短信
  5. Android(安卓)sensor 实用篇
  6. Android三角函数
  7. 2011.12.05(2)——— android JNI学习之一
  8. 面试例题6:两种方法将图像显示在View上
  9. 1.2 Android 开发环境搭建
  10. Android模仿Buttonbar(style="@android:st