Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'Fork' git repository as dependency in gradle

I made a topic some hours ago that lead me to a public repository : https://github.com/biezhi/webp-io

However, I had to update the library used, cwebp and make changes to the code. Its my first fork.

My fork is located here: https://github.com/KenobySky/webp-io

maven {url "https://jitpack.io"}
...
compile 'com.github.KenobySky:webp-io:master'

Question: Im trying to declare this 'fork' git repository as dependency in gradle but I get this error below, what should I do ?


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

References

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

like image 712
KenobiBastila Avatar asked Jun 05 '20 20:06

KenobiBastila


1 Answers

• Make sure to add maven { url 'https://jitpack.io' } inside allprojects in build.gradle project file 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
}

• Now add the dependency in build.gradle app as

android {...}

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

It works!

Alternately, You can use

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

There is a typo in your release tag and release tag title, tag has v0.06 value but the title has v0.0.6

enter image description here

You can delete this release tag and create a new one with v0.0.6 or better to use 0.0.6 as a convention.

like image 102
Pavneet_Singh Avatar answered Oct 06 '22 10:10

Pavneet_Singh