Is Jitpack needed as repository if I am using mavenCentral()? - java

So I am working on an old project in which I have the following code in the project build.gradle:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath 'com.google.gms:google-services:4.3.13'
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Android Studio is warning me to use mavenCentral() instead of jcenter() as jcenter is not being updated. So I have change it to the following code:
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath 'com.google.gms:google-services:4.3.13'
}
}
allprojects {
repositories {
google()
mavenCentral()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
So my question is, if now I am using mavenCentral() instead of jcenter(), do I have to use the " maven { url "https://jitpack.io" }" line of code or I should´t use it? I mean, the correct code
would be the following instead of the previous code? ->
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath 'com.google.gms:google-services:4.3.13'
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Or actually I should use the code line of maven jitpack (maven { url "https://jitpack.io" }") although now I am using mavenCentral() instead of jcenter()?

Or actually I should use the code line of maven jitpack (maven { url "https://jitpack.io" }") although now I am using mavenCentral() instead of jcenter()?
The choice of mavenCentral() versus jcenter() has nothing to do with jitpack.io and whether you should be using it as a repository.
You need a repository to obtain artifacts hosted by that repository. So, for example, you need the google() repository for most of Google's artifacts, such as the com.google.gms:google-services that you are using.
Whether you need jitpack.io will depend on whether you have any dependencies that come from that repository. We have no way of telling whether you do or you do not.
A comment on your question suggests removing it and seeing if your build breaks. That will not work immediately, as Gradle caches downloaded artifacts and usually works off of your cached copy. Your build would break in the future if you try updating the version of some dependency and none of the other repositories host that artifact (at least for that version).
The safest thing to do is to go through all your dependencies (everything listed in a dependencies closure in your project-level and module-level build.gradle files) and identify where they come from. Perhaps add comments to your Gradle files to help you keep track. If you find that none of your dependencies seem to come from jitpack.io, you can remove that repository.

Related

Material Search Bar from github not working

I get an error saying "Failed to resolve: com.github.mancj:MaterialSearchBar:0.8.5"
any ideas on how to fix this?
my build gradle proj
buildscript {
repositories {
google()
mavenCentral()
maven { url "https://jitpack.io" }
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.3"
classpath 'com.google.gms:google-services:4.3.10'
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build gradle app:
dependencies {
.....
implementation 'com.github.mancj:MaterialSearchBar:0.8.5'
} ```
Try adding this to your project's build.gradle(the one you showed in the first):
allprojects​ { repositories { google() mavenCentral() jcenter() } ​}
Edit: Just checked the library you were asking about. It asks you to add that maven { url ....} in the repositories section of allprojects as well:
Try adding maven { url "https://jitpack.io" } in your settings.gradle file:
settings.gradle (Project Settings)
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
maven { url "https://jitpack.io" } <-- here
}
}
rootProject.name = "StackOverflow"
include ':app'
I think this happens because Build is configured to prefer settings repositories over project repositories

How does Android search for dependencies on GitHub?

i want to implement a dependency from GitHub in my android project but it gives me this error
Could not find com.github.RobertApikyan:SegmentedControl:1.2.0
I'm implementing this:
implementation 'com.github.RobertApikyan:SegmentedControl:1.2.0'
I think is the case because by build.gradle file doesn't search on GitHub for repos.
This is my build.gradle file:
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
}
Workaround 1:
You can host a project release into mavenCentral using github, it is located at:
https://github.com/{user}/{repository}/packages?package_type=Maven
And in order to pull packages from it, add new repository in your build.gradle:
mavenCentral()
Wordaround 2:
You can host your project's any branch or version at jitpack.io
and the great thing is that you don't need to setup anything it'll build your packages in their server and notify you. Your project will be located at:
https://jitpack.io/#{user}/{repository}
And in order to pull packages from it, add new repository in your build.gradle:
maven { url 'https://jitpack.io' }

ERROR: Could not find com.android.tools.build:gradle:3.5.2

ERROR: Could not find com.android.tools.build:gradle:3.5.2.
Searched in the following locations:
-
https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.5.2/gradle-3.5.2.pom
-
https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.5.2/gradle-3.5.2.jar
- https://jcenter.bintray.com/com/android/tools/build/gradle/3.5.2/gradle-3.5.2.pom
- https://jcenter.bintray.com/com/android/tools/build/gradle/3.5.2/gradle-3.5.2.jar
Required by:
project :
Open File
ext {
var = '3.5.2'
var1 = '3.5.2'
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
// 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
}
we recived this error from my android studio when run my projects
we used online and offline mod but they not worked corectly
This error has confused me
The following code is related to wrapper
ext {
var = '3.5.2'
var1 = '3.5.2'
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
// 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
}
This problem basically occurs when you are trying to load an old project. The best solution as of my knowledge is to download the links one by one, the project is showing and sync it. Check out the build Gradle files for any outdated dependencies.
Check out if you have
google()
repo in your project. Make sure you find this line in your dependencies.
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
}
I also had this problem on Linux (ubuntu)
I tried different ways but the problem still didn't work out.
Finally, I remove /home/(user)/.gradle directory and restart Android Studio and this error fixed.
Follow these steps:
Copy paste the below code into Project level build.gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Clean your project from Build > Clean Project
Rebuild you project from Build > Rebuild Project
Make Project from Build > Make Project
Then, File > Invalidate Caches/Restart

Gradle Sync Failed to resolve: exifinterface - myhexaville smart image picker

I got this error when I used this dependency 'com.myhexaville:smart-image-picker:1.0.3'
When i commented this dependency, gradle synced successfully.
Please suggest me a proper solution for this problem.
Add Google's Maven repository to your project's build.gradle file :
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
If you are using android-studio 3.0 or above use this :
allprojects {
repositories {
jcenter()
google()
}
}

Android Studio <Failed to resolve: com.android.support:appcompat-v7:28.0.0>

i can't fix tihs problem Failed to resolve: com.android.support:appcompat-v7:28.0.0
anybody can fix this problem?
My problem
buid.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
maven {
url 'https://maven.google.com/'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
maven {
url 'https://maven.google.com/'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
First, check your build.gradle(Project), whether it was looking like below or not
Second, check your build.gradle(Module:app), whether it was looking like below or not
Please let me know, whether your issue has been resolved or not

Categories