《GitHub》上传自己的module到github作为库给别人使用(草稿待修正)
一直在想做这个,昨天试了一天终于完成了
首先我们要明确的第一点内容就是我们是module作为库给别人使用的。
所以我们创建的project的时候一定要再创建一个module,然后将库的内容放在这个module里面。
1: 创建一个项目
2: 创建一个新的module,选择Android Library
3: 上传改项目到github上面
4: 在gihub 上面生成release
5: 使用github的账号 https://jitpack.io ,然后会在项目里面找到这个项目,点击该项目的“git”的按钮
6: 在其他的项目里面就可以访问了
修改project的gradle,添加classpath两个,还有就是maven的那个 maven { url 'https://jitpack.io' }
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
//下面这两句
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
6: 在module 的gradle里面添加:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
//implementation 'com.github.kodulf:TryToGetMyGithubRepo:1.0'
implementation 'com.github.kodulf:Delete:v1.0'
//implementation 'com.github.kodulf:Try:v1.0.0'
//implementation 'com.github.kodulf:TryNotLibarary:v2.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
当“git it” 是绿色的时候,说明可以使用了,如果是report 那么就是不可以使用的,千万要注意
参考: