Could not resolve git repository as dependency in android gradle
Open Android Studio as Administrator then add maven { url 'https://jitpack.io' } to both, build.gradle(project) and settings.gradle(project) and the respective implementation [...] to build.gradle(:app). This worked for me as every other solution proposed failed.
Fork' git repository as dependency in gradle
• 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
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.
How to declare a git repository as gradle dependency if the repository is missing any tag?
Examples of using rx java with volley
That's all that repository is. Examples.
It's not a library like Volley or RxJava themselves.
You can clone that library separately from your project, and install it, run some examples, then copy the necessary sections of code to your own app.
If you did have a library that wasn't published to BinTray, then JitPack could allow you compile Github projects using tags or commit references
For reference: https://jitpack.io/#DaleKocian/VolleyAndRxJava
But, as stated, it's not a library
How to use my github repository as dependency in android?
Uploading your files to GitHub will not make your code to be available to be included as a dependency. First, make sure that your project is a library, and follow these steps to upload your library to Bintray's jcenter()
repository so that your library can be included as a dependency.
Add GitHub library as dependency to Android Studio project
It will work when you put this line in your project build.gradle
, in the dependencies
section:
compile 'com.github.chrisbanes.actionbarpulltorefresh:extra-abc:+'
Also, add:
repositories {
mavenCentral()
}
So:
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.android.support:support-v4:18.0.+'
compile 'com.android.support:appcompat-v7:18.0.+'
compile 'com.github.chrisbanes.actionbarpulltorefresh:extra-abc:+'
}
Gradle will download the needed resources automatically for you.
Create a gradle dependency to import from git
To achieve it you have some ways:
publish your library (artifact) in central maven or jcenter.
use a github repo and the jitpack plugin
publish the aar in a local maven repo (local o private)
The point 2. is very simple. Just push your codein github and modify the gradle script in the project where you want to use it.
Just add this repo tp your build.gradle
repositories {
// ...
maven { url "https://jitpack.io" }
}
and the dependency:
dependencies {
compile 'com.github.User:Repo:Tag'
}
To publish a library in Central Maven or JCenter, it is very long to explain in an answer. Hovewer you can read these posts:
Publish on JCenter
Publish on Central Maven
Android Gradle dependency on a forked GitHub project
A simple solution would be to publish your library with JitPack. You just would need to create a GitHub release and have a build file in your repository.
JitPack is a maven repository that pulls in packages from GitHub repositories. It checks out your code and builds it.
Related Topics
How to Draw a Circle with Animation in Android with Circle Size Based on a Value
Official "Boost Library" Support for Android and iOS
Android - Print Full Exception Backtrace to Log
Android: How to Get Gsm Signal Strength for All Available Network Operators
Android: How to Attach a Temporary, Generated Image to an Email
Custom Layout That Rounds the Corners of Its Content
How to Pause Flash Content in an Android Webview When My Activity Isn't Visible
Generate Barcode Image in Android Application
Android Device Chooser -- Device Not Showing Up
How to Encrypt/Decrypt String in Android
One Onclickhandler for Multiple Buttons
Detect Back Button But Don't Dismiss Dialogfragment
Voice Recognition Stops Listening After a Few Seconds
How to Change the Android App Package Name When Assembling with Gradle