'Fork' git 存储库作为 gradle 中的依赖项

Ken*_*han 6 java gradle build.gradle jitpack

几个小时前我做了一个话题,将我带到了一个公共存储库:https : //github.com/biezhi/webp-io

但是,我必须更新使用的库 cwebp 并对代码进行更改。这是我的第一个叉子。

我的叉子位于这里:https : //github.com/KenobySky/webp-io

maven {url "https://jitpack.io"}
...
compile 'com.github.KenobySky:webp-io:master'
Run Code Online (Sandbox Code Playgroud)

问题: 我试图将这个“fork”git 存储库声明为 gradle 中的依赖项,但我在下面收到此错误,我该怎么办?


Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':compileClasspath'.
  > Could not find com.github.KenobySky:webp-io:master.
    Searched in the following locations:
      - https://repo.maven.apache.org/maven2/com/github/KenobySky/webp-io/master/webp-io-master.pom
    If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
    Required by:
        project :

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org
Run Code Online (Sandbox Code Playgroud)

参考

是否可以在android gradle中将git存储库声明为依赖项?

Pav*_*ngh 8

• 确保在项目文件中添加maven { url 'https://jitpack.io' }inside作为allprojectsbuild.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    ext.kotlin_version = "1.3.72"
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.0.0"
        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()
        // Note: Add this here
        maven { url 'https://jitpack.io' }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)

• 现在将build.gradle 应用程序中的依赖项添加 为

android {...}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    // ....
    implementation 'com.github.KenobySky:webp-io:master'
}
Run Code Online (Sandbox Code Playgroud)

有用!

或者,您可以使用

implementation 'com.github.KenobySky:webp-io:0.06'
Run Code Online (Sandbox Code Playgroud)

您的发布标签和发布标签标题中存在拼写错误,标签有v0.06值但标题有v0.0.6

在此处输入图片说明

您可以删除此发布标记并创建一个新的标记v0.0.6或更好地0.0.6用作约定。