Can't connect Firebase to Android project.
-
In an attempt to connect Firebase to Android project, a mistake goes out: "Build was configured to prefer settings repositories over project repositories but repository 'Google' was added by build file 'build.gradle'." By checking, I realized the mistake was coming out of build.gradle in the lines.
allprojects { repositories { // Check that you have the following line (if not, add it): google() // Google's Maven repository } }
In the line
google() / Google's Maven repository
If this line is removed, there is no error. Help, please?
Cod build.gradle project
buildscript { repositories { google() mavenCentral() } dependencies { classpath "com.android.tools.build:gradle:7.0.3" classpath 'com.google.gms:google-services:4.3.10' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } }
allprojects {
// ...repositories { // Check that you have the following line (if not, add it): google() // Google's Maven repository // ... }
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Cod build.gradle app:
id 'com.android.application'
}android {
compileSdk 31defaultConfig { applicationId "com.example.photo42" minSdk 24 targetSdk 31 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 }
}
dependencies {
implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support.constraint:constraint-layout:2.0.4' testImplementation 'junit:junit:4.+' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
apply plugin: 'com.google.gms.google-services'
P.S. Initially in build.gradle was not allprojects. I did it myself.
-
In the new version, a mistake might be made in rows.
allprojects { // ...
repositories { // Check that you have the following line (if not, add it): google() // Google's Maven repository // ... }
}
Get them out of the gradle, that should help!