Android如何在GitHub上搜索依赖项



我想在我的android项目中实现GitHub的依赖项,但它给了我这个错误

找不到com.github.RobertApikyan:SegmentedControl:1.2.0

我正在实现这个:

implementation 'com.github.RobertApikyan:SegmentedControl:1.2.0'

我认为是这样的,因为通过build.gradle文件不会在GitHub上搜索repos。

这是我的build.gradle文件:

buildscript {
ext.kotlin_version = '1.3.72'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

解决方案1:

您可以使用github将项目发布托管到mavenCentral中,它位于:

https://github.com/{user}/{repository}/packages?package_type=Maven

为了从中提取包,请在您的构建中添加新的存储库

mavenCentral()

文字说明2:

你可以在jitpack.io上托管你项目的任何分支或版本最棒的是,你不需要设置任何东西——它会在他们的服务器中构建你的包并通知你。您的项目将位于:

https://jitpack.io/#{user}/{repository}

为了从中提取包,请在您的构建中添加新的存储库

maven { url 'https://jitpack.io' }

最新更新