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

'Fork' git repository as dependency in gradle

几个小时前我做了一个主题,它引导我进入 public 存储库: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'

问题: 我试图将此 '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

参考资料

Is it possible to declare git repository as dependency in android gradle?

• 确保在 build.gradle project 文件中的 allprojects 中添加 maven { url 'https://jitpack.io' } as

// 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
}

• 现在在 build.gradle app 中添加依赖项 as

android {...}

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

有效!

或者,您可以使用

implementation 'com.github.KenobySky:webp-io:0.06'

您的发布标签和发布标签标题有错别字,标签有 v0.06 值但标题有 v0.0.6

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