I am using one library from github to create a tableview but the tableview is showing an error in my project. I have added their implementation in my gradle file.
Library Link : https://github.com/evrencoskun/TableView
JitPack seems to be published on jcenter whose use is now deprecated in Android. All non-Google artifacts now come from mavenCentral. The solution isn't documented in the official JitPack docs, but we can use the dependencyResolutionManagement block, like,
// settings.gradle
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" }
}
}
rootProject.name = "App"
include ':app'
The code will enforce settings repositories on the repositories mentioned in build.gradle. For repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) the official docs say,
If, for some reason, a project or a plugin declares a repository in a project, Gradle would warn you. You can however make it fail the build if you want to enforce that only settings repositories are used
Refer to this answer along with this one.
Related
i am making navigation app using mapbox. but i am adding navigation-ui-0.30.0 dependency.it show this error (Failed to resolve: com.mapbox.navigator:mapbox-navigation-native:5.0.0)enter image description here
You are probably missing the following entry in your top level gradle script:
maven { url 'https://mapbox.bintray.com/mapbox' }
See installation instructions here
You have to add maven repository inside "allprojects" script in build.gradle(project level), I think you add the repository inside "buildscript". Check the following couple of line you have or not. If you have not then simply add them.
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://mapbox.bintray.com/mapbox' }
}
}
Now you have to add two dependencies in you gradle.build(app level)
implementation 'com.mapbox.mapboxsdk:mapbox-android-navigation:0.32.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-navigation-ui:0.32.0'
Now sync, make sure internet connection. Hope it will works fine then.
I'm very new to Android studio and Gradle so please be specific with your suggestions.
I downloaded this git repository because I needed a template of an app with OCR integrated into it. The project was built in Eclipse so I used the Android Studio Import tool to convert it to an Android Studio project. After attempting to build the project and resolving the first few errors by clicking on the links inside the errors, I got the "Could not find method implementation()" error which I can't seem to resolve.
NOTE - I installed Android Studio just today so I have everything updated.
This is what my build.gradle file looks like:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
implementation 'com.rmtheis:tess-two:9.0.0'
}
}
allprojects {
repositories {
jcenter()
google()
}
}
You need to add this
implementation 'com.rmtheis:tess-two:9.0.0'
in build.gradle app file under dependencies instead of build.gradle project file.
build.gradle
dependencies {
//...
implementation 'com.rmtheis:tess-two:9.0.0'
//...
}
Any clarification on this subject would be greatly appreciated.
I know this has been answered many times but my current issue is that I don't know where or in what file (s) to add this to:
buildscript {
repositories {
...
google() // <-- add this
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
And this:
allprojects {
repositories {
jcenter()
google()
}
}
Or if that even solves my issue, since I haven't tested it yet.
My initial problem:
The issue seemed to appear after updating both gradle and Android studio.
I'm currently working on a project using libGDX to make an Android app called CastleCrush. When I try to launch a desktop application to test it, it won't launch, and I get this error:
Error:Gradle: A problem occurred configuring root project
'CastleCrush'.
> Could not resolve all files for configuration ':classpath'.
> Could not find com.android.tools.build:gradle:3.0.1.
Searched in the following locations:
file:/Users/TrulsElg/.m2/repository/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
file:/Users/TrulsElg/.m2/repository/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
https://repo1.maven.org/maven2/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
https://repo1.maven.org/maven2/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
https://oss.sonatype.org/content/repositories/snapshots/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
https://oss.sonatype.org/content/repositories/snapshots/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
Required by:
project :
When launching with a virtual Android device it launches just fine.
I'm not working on this project alone and collaboration is done via Git, if that makes any difference. None of the other project members seem to have this issue.
You add this to your Project build.gradle file. its the gradle file that is called build.gradle(Project: your project name). It is usually the first one if you are in the Android project view
Could not find com.android.tools.build:gradle:3.0.1.
Gradle trying to find Android Gradle plugin version 3.0.1 artifact from your local maven repo (inside your computer) and from your listed three remote repository (maven2, oss.sonatype and jcenter).
But not succeeded because given artifact is not available on those repository.
Artifact com.android.tools.build:gradle:3.0.1 is available on google repository.
Find build.gradle file inside your libgdx project and add google maven repo inside allprojects tag
repositories {
mavenLocal()
mavenCentral()
maven { // <-- Add this
url 'https://maven.google.com/'
name 'Google'
}
}
If you're using Android Studio 3.0 or latter version
repositories {
mavenLocal()
mavenCentral()
google() //---> Add this
}
Make sure you're proper internet connection.
Cross-check that, you've not ticked offline work in Global gradle settings.
Before proceeding further take a look on LibGdx doesn't working after updating Gradle (Android Studio 3.0)
Is there any difference between google() and maven { url 'https://maven.google.com' } in build.gradle file and if there is any, what is it?
allprojects {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
// OR
google()
}
}
The google() repository is a shortcut to Google's maven repository. It was introduced in Gradle 4.x+. The actual repository URL used is `"https://dl.google.com/dl/android/maven2/" as specified here. https://maven.google.com actually points to the same repository.
However, if you are planning to use the google() shortcut, you need Gradle 4.x+, Android Studio 3.x+ and Gradle plugin for Android 3.x+.
Small correction to the answer above.
If you try to go to https://dl.google.com/dl/android/maven2/ it gives you a 404.
The correct url to google maven repository is:
https://dl.google.com/dl/android/maven2/index.html
or just
https://maven.google.com
Here you can check all the supported libraries and the latest versions.
When using gradle, you can mention multiple repositories which the build tool (gradle) uses to resolve dependencies mentioned in your project.
repositories {
jcenter()
maven { url 'https://maven.google.com' }
google()
}
In the above scenario, you're mentioning 3 repositories which gradle can use to resolve dependencies—all of which are Maven repositories.
1. jcenter()
Means the JCenter Maven repository.
This is a shortcut available in later versions of gradle
2. { url 'https://maven.google.com' }
This means you are referring a Maven repo hosted at the URL which can be used by gradle to resolve the dependencies.
If you want, you can actually enter the URL for JCenter and this would be the same as mentioning jcenter() in the gradle file.
3. google()
This means the Google Maven repository
Similar to the notation maven(), this can be used in later versions of gradle only
I have an issue with how gradle resolves my dependencies.
I have four repositories that I need to investigate for different jars, five counting Maven central. Thus my repo statment in gradle.build looks like this:
repositories {
maven {
url 'urltoRepoA'
artifactUrls mavenLocal()
}
maven {
url 'urltoRepoB'
artifactUrls mavenLocal()
}
maven {
url 'urltoRepoC'
artifactUrls mavenLocal()
}
maven {
url 'urltoRepoD'
artifactUrls mavenLocal()
}
mavenCentral()
}
What I want to acheive:
Look for dependencies both in the remote repositories and the local maven repository.
But I get this error below, that is a jar that should be resolved from repoA (repoA is a mirror of maven central, and I have verified that this jar can be found there)
[16:43:10][Step 1/3] > Could not resolve all dependencies for configuration ':runtime'.
[16:43:10][Step 1/3] > Artifact 'junit:junit:4.11#jar' not found.
According to what I've read in gradles manual is that it tries to resolve all the dependencies from the same repo. Is that what I'm running in to here? Or have I failed to configure gradle properly?
I suspect there is something wrong elsewhere in your gradle configuration. I think you are misunderstanding how gradle resolves artifacts.
According to the gradle docs (see section 8.5)
A project can have multiple repositories. Gradle will look for a
dependency in each repository in the order they are specified,
stopping at the first repository that contains the requested module.
In fact, it's rather common to have multiple repositories in a gradle script.