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
Related
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.
I have integrated a firebase real-time database in my app and I am getting a
java.lang.NullPointerException: Firebase Database component is not present
when I try to create an instance of a firebase database with the code below,
FirebaseApp firebaseApp = FirebaseApp.initializeApp(this);
mFirebaseInstance = FirebaseDatabase.getInstance(firebaseApp);
I also tried this,
mFirebaseInstance = FirebaseDatabase.getInstance();
Every time getting error Firebase Database component is not present.
Below is project gradle file code:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
//classpath 'com.google.gms:google-services:4.2.0'
classpath 'com.google.gms:google-services:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects{
repositories {
mavenCentral()
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Below are dependency which I have added
Dependencies :
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'androidx.appcompat:appcompat:1.0.0'
//implementation 'com.android.support:design:28.0.0'
implementation 'com.google.android.material:material:1.0.0-rc01'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
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'
// Firebase
implementation 'com.google.firebase:firebase-core:17.0.0'
implementation 'com.google.firebase:firebase-messaging:19.0.1'
implementation 'com.google.firebase:firebase-auth:18.0.0'
implementation 'android.arch.work:work-runtime:1.0.1'
// Firebase real time databse
implementation 'com.google.firebase:firebase-database:17.0.0'
// Glide
implementation 'com.github.bumptech.glide:glide:4.9.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
// Link preview
implementation 'io.github.ponnamkarthik:richlinkpreview:1.0.9'
implementation 'org.jsoup:jsoup:1.10.2'
// Piccaso
implementation 'com.squareup.picasso:picasso:2.71828'
//AdMob
implementation 'com.google.android.gms:play-services-ads:18.0.0'
// Needed to fix a dependency conflict with FirebaseUI'
implementation 'androidx.arch.core:core-runtime:2.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation 'androidx.test:rules:1.2.0'
}
apply plugin: 'com.google.gms.google-services'
I also tried to change the database dependency version, change class path and update google-services.json file but I am still facing the same error.
This question already has answers here:
Gradle sync failed: Plugin with id 'com.google.android.gms:play-services' not found
(3 answers)
Closed 3 years ago.
I'm trying to add Firebase to my Android app, while syncing the project I got:
Gradle sync failed: Plugin with id 'com.google.gms:google-services' not found.
I added the dependencies, google-services.json file in app root, also I added Maven repo in build.gradle top level.
1/ build.gradle top project file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.21'
repositories {
jcenter()
google()
}
allprojects {
// ...
repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
// ...
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.2.0' // Google Services plugin
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
ext {
buildToolsVersion = "25.0.2"
supportLibVersion = "25.3.1"
archRoomVersion = "1.0.0-alpha1"
}
}
2/ build.gradle // app level
dependencies {
implementation "android.arch.persistence.room:runtime:1.1.1"
implementation "android.arch.persistence.room:compiler:1.1.1"
implementation 'com.google.code.gson:gson:2.2.4'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
implementation 'io.reactivex.rxjava2:rxjava:2.1.17'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:support-vector-drawable:28.0.0'
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 "android.arch.navigation:navigation-fragment-ktx:$navigationVersion"
implementation "android.arch.navigation:navigation-ui-ktx:$navigationVersion"
implementation 'com.google.firebase:firebase-core:16.0.1'
}
buildscript {
ext {
navigationVersion = '1.0.0-alpha09'
}
}
apply plugin: 'com.google.gms:google-services' // Google Play services Gradle plugin
Any idea what should I do?
The apply plugin is wrong. Should be:
apply plugin: 'com.google.gms.google-services'
Notice the . between com.google.gms and google-services.
Also, just in case, google() should go before jcenter().
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
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
}