Reputation: 480
I want to work with firebase (firestore) using the androidx/jetpack libraries (navigation, constrintlayout, etc.). but, when adding the google services plugin in the root build.gradle, and the firebase libraries like auth and firestore in the app module build.gradle, the build fails.
1) root project build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.10'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0-alpha04'
classpath 'android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0-alpha07'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.1.0'
// 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
}
(2) app module project build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'androidx.navigation.safeargs'
android {
compileSdkVersion 28
defaultConfig {
applicationId "org.bitbucket.marlonlom.elcorral"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.10'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.0.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2'
implementation 'android.arch.navigation:navigation-fragment-ktx:1.0.0-alpha07'
implementation 'android.arch.navigation:navigation-ui-ktx:1.0.0-alpha07'
implementation 'com.google.android.material:material:1.1.0-alpha01'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.synnapps:carouselview:0.1.5'
implementation "com.google.firebase:firebase-firestore:17.1.3"
implementation "com.google.firebase:firebase-auth:16.0.5"
implementation "com.google.firebase:firebase-core:16.0.5"
implementation "com.google.android.gms:play-services-auth:16.0.1"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
}
apply plugin: 'com.google.gms.google-services'
(3) root project build.gradle
ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.android.gms:play-services-measurement-api:[16.0.3].
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.android.gms:play-services-measurement-base:[16.0.4].
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.firebase:firebase-analytics-impl:[16.2.3].
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.google.android.gms:play-services-measurement-api:[16.0.3].
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.google.android.gms:play-services-measurement-base:[16.0.4].
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.google.firebase:firebase-analytics-impl:[16.2.3].
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.google.android.gms:play-services-measurement-api:[16.0.3].
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.google.android.gms:play-services-measurement-base:[16.0.4].
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.google.firebase:firebase-analytics-impl:[16.2.3].
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.google.android.gms:play-services-measurement-api:[16.0.3].
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.google.android.gms:play-services-measurement-base:[16.0.4].
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.google.firebase:firebase-analytics-impl:[16.2.3].
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.google.android.gms:play-services-measurement-api:[16.0.3].
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.google.android.gms:play-services-measurement-base:[16.0.4].
Show Details
Affected Modules: app
ERROR: Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.google.firebase:firebase-analytics-impl:[16.2.3].
Show Details
Affected Modules: app
Any help with this?
Best regards,
Upvotes: 1
Views: 1621
Reputation: 480
First of all, thanks for the comments: @peter-haddad and @achraf-amil
After all, I made this for fixing the build.gradle files i mentioned before, in terms of reviewing the versions of the libraries i used:
(1) In root build.gradle:
...
dependencies{
...
classpath 'com.android.tools.build:gradle:3.4.0-alpha05'
...
//noinspection GradleDependency
classpath 'com.google.gms:google-services:4.0.2'
...
}
additionally, i listed the versions of the dependencies here.
...
ext {
kotlin_version = '1.3.10'
/* androidx related dependencies */
androidx_appcompat_version = '1.0.2'
androidx_core_ktx_version = '1.0.1'
androidx_constraintlayout_version = '2.0.0-alpha2'
androidx_legacy_support_v4_version = '1.0.0'
android_arch_navigation_fragment_ktx_version = '1.0.0-alpha07'
android_arch_navigation_ui_ktx_version = '1.0.0-alpha07'
google_material_version = '1.1.0-alpha01'
/* firebase dependencies */
firebase_firestore_version = '17.1.1'
firebase_auth_version = '16.0.4'
firebase_storage_version = '16.0.3'
firebase_core_version = '16.0.4'
play_services_auth_version = '16.0.1'
/* other dependencies */
synnapps_carouselview_version = '0.1.5'
/* Testing dependencies versions*/
junit_version = '4.12'
androidx_test_runner_version = '1.1.0'
androidx_test_espresso_core_version = '3.1.0'
}
(2) In app module build.gradle, i applied the versions as variable in the dependencies block:
...
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$rootProject.kotlin_version"
implementation "androidx.core:core-ktx:$rootProject.androidx_core_ktx_version"
implementation "androidx.constraintlayout:constraintlayout:$rootProject.androidx_constraintlayout_version"
implementation "android.arch.navigation:navigation-fragment-ktx:$rootProject.android_arch_navigation_fragment_ktx_version"
implementation "android.arch.navigation:navigation-ui-ktx:$rootProject.android_arch_navigation_ui_ktx_version"
implementation "com.google.android.material:material:$rootProject.google_material_version"
implementation "androidx.legacy:legacy-support-v4:$rootProject.androidx_legacy_support_v4_version"
implementation "com.synnapps:carouselview:$rootProject.synnapps_carouselview_version"
implementation "com.google.android.gms:play-services-auth:$rootProject.play_services_auth_version"
//noinspection GradleDependency
implementation "com.google.firebase:firebase-firestore:$rootProject.firebase_firestore_version"
//noinspection GradleDependency
implementation "com.google.firebase:firebase-auth:$rootProject.firebase_auth_version"
//noinspection GradleDependency
implementation "com.google.firebase:firebase-storage:$rootProject.firebase_storage_version"
//noinspection GradleDependency
implementation "com.google.firebase:firebase-core:$rootProject.firebase_core_version"
testImplementation "junit:junit:$rootProject.junit_version"
androidTestImplementation "androidx.test:runner:$rootProject.androidx_test_runner_version"
androidTestImplementation "androidx.test.espresso:espresso-core:$rootProject.androidx_test_espresso_core_version"
}
apply plugin: 'com.google.gms.google-services'
the //noinspection GradleDependency text part helped in the check of different versions of the library versus google play library versions.
IDK if this is the recommended way, but it worked (for now).
Regards,
Upvotes: 0
Reputation: 1375
Had the same problem, try previous versions. The latest version that works for me (as of today) is 17.1.0
https://mvnrepository.com/artifact/com.google.firebase/firebase-firestore
Upvotes: 2