Failed to resolve: com.android.support.constraint:constraint-layout:1.0.2
I see this error when I open my projectI cant install constraint-layout:1.0.2, there is some error strong text
Your project's build.gradle should have the content as below.
All the Google specific dependencies are now hosted on their own Maven Repository.
If you still find it confusing, just create a new Project from scratch using Android Studio 3.0.1 and all the dependencies would be properly configured.
buildscript {
repositories {
google() // Speficically this entry
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
First of all, make sure to update your Android Studio. Second thing, make sure you import the Google maven repository into your project gradle file. Then, you should be able to install ConstraintLayout.
Here's the solution:
repositories {
maven {
url 'https://maven.google.com'
}
}
then add this line in dependencies:
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support.constraint:constraint-layout-solver:1.0.2'
Related
every time i create a new android studio project, the layout editor will be broken because the dependency com.android.support:appcompat-v7:28.0.0-alpha3 will spoil the layout editor with:
Render problem
Failed to load AppCompat ActionBar with unknown error.
Tip: Try to refresh the layout.
thanks to user JLC answer, the problem is solved, but if i create a new project, the problem will come back
so my question is how can i change it so that every new project will use dependency com.android.support:appcompat-v7:27.1.1 instead? thanks
If you are using Android Studio 3.0 and above then make sure you are using the same content in build.gradle like-
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
And for below Android Studio 3.0 and starting from support libraries 26.+ your project build.gradle must look like this-
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
For the detailed knowledge check the below docs-
Build Dependencies
Building Android apps
Configure your build
I have been tryong to add FCM to my android application for almost 48 hours now. I am keep on failing with these two errors on Android Studio. I have tried all the solutions in this post. Still I couldn't fix it.
I want firebase cloud messaging to be integrated in my app. So I did the followings.
Created an app in the firebase console
Included the .json config file
Added the SDK
implementation 'com.google.firebase:firebase-messaging:17.0.0'
(In the app level gradle)
apply plugin: 'com.google.gms.google-services' (In the app level gradle file last
line)
classpath 'com.google.gms:google-services:4.0.1'
(In the project level gradle)
Added the repository
google() (In the project level gradle)
I have tried syncing many times and I keep on getting the error
Failed to resolve: play-services-tasks Open File
Failed to resolve: play-services-basement Open File
On a side note, I am using the gradle plugin 3.1.3
classpath 'com.android.tools.build:gradle:3.1.3'
Can someone please give me a hand here please.
In gradle (project),
just change the position of google() before jcenter(),
and the error is gone.
repositories {
google()
jcenter()
}
jcenter() sometimes act as a mirror repository for some Google dependencies. During Gradle building process, it looks for dependencies in the first entry listed in your repositories {...} block. So if this repository is broken or something bad occurs with any dependency the process will fail.
Here there is a recommended order for repository list
repositories {
google()
maven {
url 'https://maven.google.com/'
}
jcenter()
}
Put google() repository at the very first line of dependencies. It will work.
Add in your app.gradle
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
and upgrade your dependencies version.
I had this occurring due to outdated build tools version. Updating from 28.0.2 to 28.0.3 resolved it.
buildToolsVersion '28.0.2'
to:
buildToolsVersion '28.0.3'
in build.gradle file.
So this is a little new to me, I am using adblock project and showing my website from webviewer but i want to not show my website's ads into it, so i used adblock project for the same. But somehow i am getting this weird error of not founding
com.google.android.gms:play-services-ads:15.0.0
Failed to resolve: com.google.android.gms:play-services-ads:15.0.0
Install Repository and sync project
Show in File
Show in Project Structure dialog
After i clicked on Install Repository and sync project the SDK manager says
Could not find dependency "com.google.android.gms:play-services-ads:15.0.0"
Configs:
In build.gradle(project)
buildscript {
repositories {
mavenLocal()
mavenCentral()
jcenter()
maven {
url "https://maven.google.com"
}
And in build.gradle(Module:libadblockerplus-android-webviewapp)
dependencies {
compile project(':libadblockplus-android-settings')
compile project(':libadblockplus-android-webview')
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services-ads:15.0.0'
}
adding
maven {
url "https://maven.google.com"
}
to the other repositories block in your build.gradle file. Fixed the issue. Thanks #stkent
You should add
maven {
url "https://maven.google.com"
}
to the other repositories block in your build.gradle file.
From your posted snippet, it appears you have already added it to the buildscript block's list of repositories. However, those repositories are only used to search for dependencies for the building of your application. See this SO question for more discussion on the difference between the repositories and buildscript.repositories blocks.
I tried to add the Google location Service to my Android Project by referencing the official link.
As the tutorial said I added the following line to the dependencies section in the Project Gradle file.
implementation "com.google.android.gms:play-services-location:11.8.0"
But when i resynced the project i got the following error
Error:(19, 0) Could not find method implementation() for arguments [com.google.android.gms:play-services-location:11.8.0] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Open File
I am using Android Studio 3.0.1 and Gradle Version 4.1.
How to overcome this error?
please try this
Add in Build.gradel at app lavel
dependencies {
Implementation 'com.google.android.gms:play-services:9.6.0'
}
apply plugin: 'com.google.gms.google-services
// Top-level build file where you can add configuration options common
to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they
belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I think you have forgot to add maven repository in your app gradle file. Try by doing these steps. Open the build.gradle file for your application. Make sure that the repositories section includes a maven section with the "https://maven.google.com" endpoint. For example: allprojects {repositories {jcenter()maven {url "https://maven.google.com"}}}
Avoid using + in your dependencies as it android studio will try to update dependencies every 24 hours. Also replace compile by implementation for low APK size.
Edit 1:
As you told maven repository did not worked.
Check your project settings by going to Android Studio.
Click on file
click on project structure
There will option of Project in sidebar. Tap on it.
Check for the gradle and andrpid plugin version.
Put these values
Gradle Version - 4.1
Android plugin version - 3.0.1
Android Plugin Repository - jcenter,google()
Default Library Repository - jcenter, 'https://maven.google.com'
Reply me if it works
I'm getting the following error when trying to compile my app:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':myProject'.
> Could not resolve all files for configuration ':myProject:classpath'.
> Could not find org.jetbrains.trove4j:trove4j:20160824.
Searched in the following locations:
https://repo1.maven.org/maven2/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.pom
https://repo1.maven.org/maven2/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.jar
https://maven.fabric.io/public/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.pom
https://maven.fabric.io/public/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.jar
https://maven.google.com/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.pom
https://maven.google.com/org/jetbrains/trove4j/trove4j/20160824/trove4j-20160824.jar
Required by:
project :metam > com.android.tools.build:gradle:3.0.0-beta2 > com.android.tools.build:gradle-core:3.0.0-beta2 >
com.android.tools.lint:lint:26.0.0-beta2 > com.android.tools.lint:lint-checks:26.0.0-beta2 > com.android.tools.lint:lint-
api:26.0.0-beta2 > com.android.tools.external.com-intellij:intellij-core:26.0.0-beta2
It appears a library the IDE needs is missing?
this issue can be resolved by adding jcenter() as a repository in the buildscript section.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-beta2'
}
}
Additional to Snicolas' answer:
If you have something like:
allprojects {
repositories {
mavenCentral()
google()
jcenter() //also add it here!!!
}
}
In your build.gradle file; also add it there.
Since jCenter will close in May, you should change root/build.gradle so:
buildscript {
repositories {
google()
gradlePluginPortal()
}
}
allprojects {
repositories {
google()
mavenCentral()
// org.jetbrains.trove4j:trove4j:20160824.
gradlePluginPortal()
}
}
See also https://stackoverflow.com/a/66168563/2914140 to add libraries not included in Maven.
Now we can build apk without errors.
If you're seeing this error after May 1st 2021, it's probably because jcenter is shut down. It's needed by the Android Gradle Plugin (AGP). Google devs have said they're using a newer version of the library that can be got from mavenCentral() as of AGP 7 and hoping to backport that into AGP 4.2 and 4.1. So first of all, try and upgrade to AGP 7. And if I haven't edited this post with updates, check to see is it in any lower AGP versions.
But if you can't upgrade AGP, as of initial time of posting (February 2021), the only repo I could find with the trove package is on pentaho, which seems to be owned by Hitachi so I presume it's safe.
buildscript {
repositories {
maven { url "https://nexus.pentaho.org/content/groups/omni" }
}
dependencies {
classpath 'org.jetbrains.trove4j:trove4j:20160824'
}
}
This is NOT an ideal solution. This repo could be intended to be private for all I know. Look for a better answer that might be posted after me.
I solved this problem
deleting in build.gradlew
repositories {
jcenter()
}
And change the mavenCentral() to jcenter() and deleting google()
Migrating away from jcenter? jcenter will sunset on the 1st of May
You may face this issue if you are migrating away from jcenter. The issue happens because Trove4j library was being fetched from jcenter and you removed jcenter repository while migrating away from jcenter.
Solution:
Add the following to the project build.gradle:
maven { url 'https://plugins.gradle.org/m2/' }
It should be added to:
build.gradle(peoject) -> buildscript -> repositories
build.gradle(peoject) -> allprojects -> repositories
buildscript {
repositories {
google()
mavenCentral()
// ** Add this line **
maven { url 'https://plugins.gradle.org/m2/' }
}
}
allprojects {
repositories {
google()
mavenCentral()
// ** Add this line **
maven { url 'https://plugins.gradle.org/m2/' }
}
}
Since jcenter will sunset on 1st of May, 2021. jcenter repository should be removed from the project. This means that all occurrences to "jcenter()" should be removed. This can lead to an issues with the libraries hosted by jcenter. You should provide another repository that host the library such as maven. Some unmaintained libraries maybe are not moved to any other repository. In this case, you might need to consider opening an issue for the library or not using it. You will face all these issues on the 1st of May and you may be unable to build your app if you are not doing the migration now.
Just delete .idea,.gradle and gradle folder and restart your application.
Try to replace mavenCentral() with jcenter() in your build.gradle file
allprojects {
repositories {
jcenter()
//.......
}
}
Go to Help->About in Android Studio and check your version. Enter that vesion in build.gradle App Mudule & same for project build.gradle as done in the
classpath line here:
buildscript {
...
repositories {
...
}
dependencies {
...
classpath "com.android.tools.build:gradle:{THREE.DIGIT.VERSION}"
}
}
This was happening to me every time I upgraded the Gradle Plugin, so what I did and worked:
Delete your package-lock.json or yarn.lock
Run npm i or yarn to update all node modules in your project
Rename your ios project to ios_ for example
Run react-native link to link all dependencies again to your android project
Rename back ios_ to ios
Check the file (project/build.gradle) what Gradle Plugin version you're using. The version 3.4.1 worked for me.
Check your Gradle version (gradle/wrapper/gradle-wrapper.properties), the version 5.4.1 worked here.
Open your Android project using Android Studio, navigate to Build > "Rebuild project"
And finally, try sync/build again.
Hope it can help someone.