AndroidX ERROR: Failed to resolve: appcompat - android

When I create a new project, I have these dependencies as default :
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
Syncing project fails at the beginning and I can't fix it. The error is for 'androidx.appcompat:appcompat:1.1.0' gradle can't resolve this dependency.
Error log :
ERROR: Failed to resolve: appcompat
Affected Modules: app
Gradle Module Project :
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
}
I checked the download URL and the result is 404 : https://dl.google.com/dl/android/maven2/androidx/appcompat/appcompat/1.1.0
Any idea how to fix it ?

Try this:-
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation "androidx.core:core-ktx:1.1.0"

Surprisingly with deleting the Gradle Home (.gradle) problem solved. Probably corrupted cache or something had made the bug.

Related

ERROR: Failed to resolve: androidx.legacy:legacy-support-v4

After migrating to androidx this error kept showing, can anyone help me with it?
Here's part of the build.gradle
buildscript {
repositories {
google()
maven {
url 'https://maven.google.com'
}
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
// 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'
}
jcenter()
}
}
here's the list of dependencies in build.gradle(app)
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'androidx.legacy:legacy-support-v4'
//implementation 'androidx.legacy:legacy-support-v13'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.3.0-alpha02'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha02'
}
this is the single line of error when I try to sync project
ERROR: Failed to resolve: androidx.legacy:legacy-support-v4:
Affected Modules: app
Use
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
instead of
implementation 'androidx.legacy:legacy-support-v4'

Failed to resolve test runner dependency in gradle

I am creating new project in android studio but after building project it is showing error below:
ERROR: Failed to resolve: androidx.test.espresso:espresso-core:3.2.1
Show in Project Structure dialog
Affected Modules: app
ERROR: Failed to resolve: androidx.test:runner:1.2.1
Show in Project Structure dialog
Affected Modules: app
Below is my gradle files dependencies:
app.gradle
dependencies {
def lifecycle_version = "2.0.0"
def room_version = "2.2.0-alpha01"
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.1'
androidTestImplementation 'androidx.test:runner:1.2.1'
//View model and live data
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
annotationProcessor "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"
//Room
implementation "androidx.room:room-runtime:$room_version"
annotationProcessor "androidx.room:room-compiler:$room_version"
testImplementation "androidx.room:room-testing:$room_version"
}
Notes
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.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
}
Someone please let me know why above error is showing and how can I overcome it. Any help would be appreciated.
THANKS
Where did your version come from? Official only to 3.1.0
Reference this https://developer.android.com/training/testing/set-up-project

Error: Program type already present: com.google.android.gms.internal.measurement.zzfg

I tried find solution on internet but nothink work for me.
After implement firebase analytics my program display this error.
Error: Program type already present: com.google.android.gms.internal.measurement.zzfg
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.0.1'
// 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
}
build.gradle (Module:app)
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
implementation 'com.google.android.gms:play-services-ads:17.1.1'
implementation 'com.google.firebase:firebase-database:16.0.5'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.google.firebase:firebase-analytics:16.0.6';
implementation 'com.google.firebase:firebase-crash:16.2.1'
implementation 'com.google.firebase:firebase-config:16.1.2'
com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
}
Try updating the dependencies to the latest version for
com.google.android.gms:play-services and com.google.firebase:
Looks like it was discussed here:
com.google.android.gms:play-services-measurement-base is being requested by various other libraries

Google Play Services - Could not find dependency

I'm building an app for the first time, it worked well with Google Map but a problem appeared when i added Firebase to my app.
I change some dependencies and this error occured after syncing with Gradle file :
Failed to resolve: com.google.android.gms:play-services:15.0.1
Install Repository and sync project
Show in File
Show in Project Structure dialog
Obviously i tried to click on Install Repository and sync project. During the installation, another error occured :
Could not find dependency "com.google.android.gms:play-services:15.0.1"
Here is my dependencies in build.gradle file. As you can see, i didn't forget to use implementation 'com.google.android.gms:play-services:15.0.1'.
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:support-annotations:28.0.0-alpha3'
implementation 'com.google.firebase:firebase-auth:16.0.2'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.android.gms:play-services:15.0.1'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'com.google.android.gms:play-services-identity:15.0.1'
implementation 'com.google.android.gms:play-services-location:15.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
I found people with the same problem and i tried lots of proposed solutions, but the problem isn't solved.
You can see below my build.gradle project file.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.google.gms:google-services:4.0.1'
classpath 'com.android.tools.build:gradle:3.3.0-alpha03'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

After updating Gradle dependencies failed to resolve

After update gradle to latest dependencies contain firebase and play services:
Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
Failed to resolve: play-services-base
Open File
Failed to resolve: play-services-tasks
Open File
Failed to resolve: play-services-stats
Open File
Failed to resolve: play-services-ads-identifier
Open File
Failed to resolve: play-services-basement
Open File
build.gradle(app)
implementation 'com.google.firebase:firebase-messaging:17.0.0'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.android.gms:play-services-analytics:16.0.0'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'com.google.android.gms:play-services-places:15.0.1'
How can I resolve?
I resolved issue.
This is solution
1.add google() before jcenter()
2.exclude group:"com.google.android.gms" in facebook sdk dependencies
My code
Gradle :
buildscript {
repositories {
google()
jcenter()
}
// something here ...
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath "io.realm:realm-gradle-plugin:3.1.1"
classpath 'com.google.gms:google-services:4.0.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And Myapp/gradle :
repositories {
maven { url 'https://maven.fabric.io/public' }
google()
jcenter()
}
dependencies {
implementation('com.crashlytics.sdk.android:crashlytics:2.8.0#aar') {
transitive = true
}
implementation ('com.facebook.android:account-kit-sdk:4.28.0'){
exclude group:"com.google.android.gms"
}
implementation 'com.facebook.android:facebook-android-sdk:4.32.0'
implementation 'com.googlecode.libphonenumber:libphonenumber:8.9.4'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.4.2'
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'com.android.support:multidex:1.0.3'
implementation files('libs/glide-3.8.0.jar')
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation('com.squareup.okhttp:okhttp-urlconnection:2.3.0') {
exclude group: 'com.squareup.okhttp', module: 'okhttp'
}
implementation('com.squareup.okhttp:okhttp:2.3.0') {
exclude group: 'com.squareup.okio', module: 'okio'
}
implementation 'me.relex:circleindicator:1.2.2#aar'
implementation 'com.android.support:exifinterface:27.1.1'
implementation 'com.google.firebase:firebase-messaging:17.0.0'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.android.gms:play-services-analytics:16.0.0'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'com.google.android.gms:play-services-places:15.0.1'
}
apply plugin: 'com.google.gms.google-services'
I have the same problem and resolved by this:
In Gradle (project), just change the position of google() before jcenter(), and Sync and the error is gone.
repositories {
google()
jcenter()
}
And here is the explanation. Someone had the brilliant idea of uploading to JCenter only the pom definition for com.google.android.gms:play-services-basement:15.0.1 meaning that if JCenter was your first option, it would find the POM file and would attempt to download the AAR from the same location, but it hasn't been upload there. Switching the repositories order with google() now first, it will find both the POM and AAR correctly on Google's repository.
Running gradle app:build from command line would tell you what Android Studio doesn't:
* What went wrong:
Could not resolve all files for configuration ':app:debugCompileClasspath'.
> Could not find play-services-basement.aar (com.google.android.gms:play-services-basement:15.0.1).
Searched in the following locations:
https://jcenter.bintray.com/com/google/android/gms/play-services-basement/15.0.1/play-services-basement-15.0.1.aar
You can see the artifact on JCenter's website, it only contains the POM.
https://bintray.com/bintray/jcenter/com.google.android.gms%3Aplay-services-basement#files/com%2Fgoogle%2Fandroid%2Fgms%2Fplay-services-basement%2F15.0.1
While Google repository has the complete set:
https://maven.google.com/com/google/android/gms/play-services-basement/15.0.1/play-services-basement-15.0.1.pom
https://maven.google.com/com/google/android/gms/play-services-basement/15.0.1/play-services-basement-15.0.1.aar

Categories

Resources