Apply Firebase to Android Studio Project version Bumblebee - android

I'm trying to add Firebase SDK, follow the step guide of Firebase:
enter image description here
but the new version of Android Studio has a different build.gradle file, just:
plugins {
id 'com.android.application' version '7.1.1' apply false
id 'com.android.library' version '7.1.1' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And I don't know how right to add code to my file. I've tried this:
buildscript {
repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
}
dependencies {
// Add this line
classpath 'com.google.gms:google-services:4.3.10'
}
}
plugins {
id 'com.android.application' version '7.1.1' apply false
id 'com.android.library' version '7.1.1' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
allprojects {
repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
}
}
But the log here is:
org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'Uber clone'
Caused by: org.gradle.api.InvalidUserCodeException: Build was configured to prefer settings repositories over project repositories but repository 'Google' was added by build file 'build.gradle
at build_8l5l0a77l47futp20icywdlc2$_run_closure2$_closure3.doCall(D:\Android\AndroidProjects\Uberclone\build.gradle:25)
at build_8l5l0a77l47futp20icywdlc2$_run_closure2.doCall(D:\Android\AndroidProjects\Uberclone\build.gradle:23)
at build_8l5l0a77l47futp20icywdlc2.run(D:\Android\AndroidProjects\Uberclone\build.gradle:22)

There is no need to add the repositories and the allprojects inside the Gradle file. This is because both are already present inside the setting.gradle file. To solve this simply remove them as you can see below:
buildscript {
dependencies {
// Add this line
classpath 'com.google.gms:google-services:4.3.10'
}
}
plugins {
id 'com.android.application' version '7.1.1' apply false
id 'com.android.library' version '7.1.1' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}

I resolved this issue by commenting out 'dependencyResolutionManagement' section which is present in the settings.gradle.
Go to Gradle Scripts -> settings.gradle -> comment out 'dependencyResolutionManagement'
//dependencyResolutionManagement {
// repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
// repositories {
// google()
// mavenCentral()
// }
//}
Then paste the all project repository in Gradle Scripts -> build.gradle -> paste it below 'plugins' section
like this-
plugins {
id 'com.android.application' version '7.3.1' apply false
id 'com.android.library' version '7.3.1' apply false
}
allprojects {
repositories {
// Make sure that you have the following two repositories
google() // Google's Maven repository
mavenCentral() // Maven Central repository
}
}

Related

how to connect firebase to android studio [duplicate]

I just updated Android Studio and started a new project. But now the project grade file seems different.
Here are the lines:
plugins {
id 'com.android.application' version '7.1.0' apply false
id 'com.android.library' version '7.1.0' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Now, for example, I need to paste the Firebase lines in the project level Gradle file. Where should I do it?
Here's the Firebase code:
buildscript {
repositories {
google() // Google's Maven repository
}
dependencies {
classpath 'com.google.gms:google-services:4.3.10'
}
}
allprojects {
repositories {
google() // Google's Maven repository
}
}
In all of my previous projects, the Gradle structure was also like that. Now I'm a little confused about what to do.
But now the project grade file seems different.
Yes, starting with the new Bumblebee update of Android Studio, the build.gradle (Project) file is changed. In order to be able to use Google Services, you have to add to your build.gradle (Project) file the following lines:
plugins {
id 'com.android.application' version '7.1.0' apply false
id 'com.android.library' version '7.1.0' apply false
id 'com.google.gms.google-services' version '4.3.0' apply false 👈
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And inside your build.gradle (Module) file, the following plugin IDs:
plugins {
id 'com.android.application'
id 'com.google.gms.google-services' 👈
}
In this way, your Firebase services will finally work.
P.S. Not 100% sure if the Firebase Assistant is updated with these new Android Studio changes.
Edit 2022-14-07:
Here is a repo that uses this new structure:
https://github.com/alexmamo/FirestoreCleanArchitectureApp
Edit:
There is nothing changed regarding the way you add dependencies in the build.gradle (Module) file. If for example, you want to add Firestore and Glide, please use:
dependencies {
//Regular dependecies
implementation platform("com.google.firebase:firebase-bom:29.0.4")
implementation "com.google.firebase:firebase-firestore"
implementation "com.github.bumptech.glide:glide:4.12.0"
}
Edit2:
With the new updates, you don't need to worry about adding any lines under the repositories { }. That was a requirement in the previous versions.
I've had the same problem just add in the gradle.build project
id 'com.google.gms.google-services' version '4.3.0' apply false
and then add in gradle.build module
dependencies {
//Regular dependecies
implementation platform("com.google.firebase:firebase-bom:30.4.0")
implementation "com.google.firebase:firebase-firestore"
}
You will find your classpath from https://console.firebase.google.com/
You will find something like this in the firebase(if you already got your classpath then you can ignore this section)
buildscript {
repositories {
// Make sure that you have the following two repositories
google() // Google's Maven repository
mavenCentral() // Maven Central repository
}
dependencies {
...
// Add the dependency for the Google services Gradle plugin
classpath 'com.google.gms:google-services:4.3.13'
}
}
allprojects {
...
repositories {
// Make sure that you have the following two repositories
google() // Google's Maven repository
mavenCentral() // Maven Central repository
}
}
just copy the classpath
1)In build.gradle(project)
before plugins make these changes-->
buildscript {
dependencies {
classpath 'com.google.gms:google-services:4.3.13'
}
}
plugins {
id 'com.android.application' version '7.2.2' apply false
id 'com.android.library' version '7.2.2' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
2)In build.gradle(module) add these lines in pulgins and dependencies section
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}
dependencies {
implementation platform('com.google.firebase:firebase-bom:30.2.0')
implementation 'com.google.firebase:firebase-analytics'
}

Android Studio build.gradle Missing Elements [duplicate]

I just updated Android Studio and started a new project. But now the project grade file seems different.
Here are the lines:
plugins {
id 'com.android.application' version '7.1.0' apply false
id 'com.android.library' version '7.1.0' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Now, for example, I need to paste the Firebase lines in the project level Gradle file. Where should I do it?
Here's the Firebase code:
buildscript {
repositories {
google() // Google's Maven repository
}
dependencies {
classpath 'com.google.gms:google-services:4.3.10'
}
}
allprojects {
repositories {
google() // Google's Maven repository
}
}
In all of my previous projects, the Gradle structure was also like that. Now I'm a little confused about what to do.
But now the project grade file seems different.
Yes, starting with the new Bumblebee update of Android Studio, the build.gradle (Project) file is changed. In order to be able to use Google Services, you have to add to your build.gradle (Project) file the following lines:
plugins {
id 'com.android.application' version '7.1.0' apply false
id 'com.android.library' version '7.1.0' apply false
id 'com.google.gms.google-services' version '4.3.0' apply false 👈
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And inside your build.gradle (Module) file, the following plugin IDs:
plugins {
id 'com.android.application'
id 'com.google.gms.google-services' 👈
}
In this way, your Firebase services will finally work.
P.S. Not 100% sure if the Firebase Assistant is updated with these new Android Studio changes.
Edit 2022-14-07:
Here is a repo that uses this new structure:
https://github.com/alexmamo/FirestoreCleanArchitectureApp
Edit:
There is nothing changed regarding the way you add dependencies in the build.gradle (Module) file. If for example, you want to add Firestore and Glide, please use:
dependencies {
//Regular dependecies
implementation platform("com.google.firebase:firebase-bom:29.0.4")
implementation "com.google.firebase:firebase-firestore"
implementation "com.github.bumptech.glide:glide:4.12.0"
}
Edit2:
With the new updates, you don't need to worry about adding any lines under the repositories { }. That was a requirement in the previous versions.
I've had the same problem just add in the gradle.build project
id 'com.google.gms.google-services' version '4.3.0' apply false
and then add in gradle.build module
dependencies {
//Regular dependecies
implementation platform("com.google.firebase:firebase-bom:30.4.0")
implementation "com.google.firebase:firebase-firestore"
}
You will find your classpath from https://console.firebase.google.com/
You will find something like this in the firebase(if you already got your classpath then you can ignore this section)
buildscript {
repositories {
// Make sure that you have the following two repositories
google() // Google's Maven repository
mavenCentral() // Maven Central repository
}
dependencies {
...
// Add the dependency for the Google services Gradle plugin
classpath 'com.google.gms:google-services:4.3.13'
}
}
allprojects {
...
repositories {
// Make sure that you have the following two repositories
google() // Google's Maven repository
mavenCentral() // Maven Central repository
}
}
just copy the classpath
1)In build.gradle(project)
before plugins make these changes-->
buildscript {
dependencies {
classpath 'com.google.gms:google-services:4.3.13'
}
}
plugins {
id 'com.android.application' version '7.2.2' apply false
id 'com.android.library' version '7.2.2' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
2)In build.gradle(module) add these lines in pulgins and dependencies section
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}
dependencies {
implementation platform('com.google.firebase:firebase-bom:30.2.0')
implementation 'com.google.firebase:firebase-analytics'
}

"android studio w/ kotlin" curiosity with gradle file for project

i'm studying how to use tensorflow lite on android studio with kotlin, and i got a problem now. i was referring a project to study, and this author's gradle file is very different with what i have been knowing.
plugins {
id 'com.android.application' version '7.1.3' apply false
id 'com.android.library' version '7.1.3' apply false
id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
--> this is what i have been knowing from the first time.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.4"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
--> and this is the gradle file for project that i'm reffering.
what i'm wondering aboout is why the author is not using plugins{} and having buildscript{} and allprojects{}. plus even though i copied and pasted it on the new project that i made, it does not work and throws the error.
error message img
what should i do for this?

Stuck to firebase set up step 3 [duplicate]

I just updated Android Studio and started a new project. But now the project grade file seems different.
Here are the lines:
plugins {
id 'com.android.application' version '7.1.0' apply false
id 'com.android.library' version '7.1.0' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Now, for example, I need to paste the Firebase lines in the project level Gradle file. Where should I do it?
Here's the Firebase code:
buildscript {
repositories {
google() // Google's Maven repository
}
dependencies {
classpath 'com.google.gms:google-services:4.3.10'
}
}
allprojects {
repositories {
google() // Google's Maven repository
}
}
In all of my previous projects, the Gradle structure was also like that. Now I'm a little confused about what to do.
But now the project grade file seems different.
Yes, starting with the new Bumblebee update of Android Studio, the build.gradle (Project) file is changed. In order to be able to use Google Services, you have to add to your build.gradle (Project) file the following lines:
plugins {
id 'com.android.application' version '7.1.0' apply false
id 'com.android.library' version '7.1.0' apply false
id 'com.google.gms.google-services' version '4.3.0' apply false 👈
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And inside your build.gradle (Module) file, the following plugin IDs:
plugins {
id 'com.android.application'
id 'com.google.gms.google-services' 👈
}
In this way, your Firebase services will finally work.
P.S. Not 100% sure if the Firebase Assistant is updated with these new Android Studio changes.
Edit 2022-14-07:
Here is a repo that uses this new structure:
https://github.com/alexmamo/FirestoreCleanArchitectureApp
Edit:
There is nothing changed regarding the way you add dependencies in the build.gradle (Module) file. If for example, you want to add Firestore and Glide, please use:
dependencies {
//Regular dependecies
implementation platform("com.google.firebase:firebase-bom:29.0.4")
implementation "com.google.firebase:firebase-firestore"
implementation "com.github.bumptech.glide:glide:4.12.0"
}
Edit2:
With the new updates, you don't need to worry about adding any lines under the repositories { }. That was a requirement in the previous versions.
I've had the same problem just add in the gradle.build project
id 'com.google.gms.google-services' version '4.3.0' apply false
and then add in gradle.build module
dependencies {
//Regular dependecies
implementation platform("com.google.firebase:firebase-bom:30.4.0")
implementation "com.google.firebase:firebase-firestore"
}
You will find your classpath from https://console.firebase.google.com/
You will find something like this in the firebase(if you already got your classpath then you can ignore this section)
buildscript {
repositories {
// Make sure that you have the following two repositories
google() // Google's Maven repository
mavenCentral() // Maven Central repository
}
dependencies {
...
// Add the dependency for the Google services Gradle plugin
classpath 'com.google.gms:google-services:4.3.13'
}
}
allprojects {
...
repositories {
// Make sure that you have the following two repositories
google() // Google's Maven repository
mavenCentral() // Maven Central repository
}
}
just copy the classpath
1)In build.gradle(project)
before plugins make these changes-->
buildscript {
dependencies {
classpath 'com.google.gms:google-services:4.3.13'
}
}
plugins {
id 'com.android.application' version '7.2.2' apply false
id 'com.android.library' version '7.2.2' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
2)In build.gradle(module) add these lines in pulgins and dependencies section
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}
dependencies {
implementation platform('com.google.firebase:firebase-bom:30.2.0')
implementation 'com.google.firebase:firebase-analytics'
}

Build Gradle looks different. How to I install Firebase? [duplicate]

I just updated Android Studio and started a new project. But now the project grade file seems different.
Here are the lines:
plugins {
id 'com.android.application' version '7.1.0' apply false
id 'com.android.library' version '7.1.0' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Now, for example, I need to paste the Firebase lines in the project level Gradle file. Where should I do it?
Here's the Firebase code:
buildscript {
repositories {
google() // Google's Maven repository
}
dependencies {
classpath 'com.google.gms:google-services:4.3.10'
}
}
allprojects {
repositories {
google() // Google's Maven repository
}
}
In all of my previous projects, the Gradle structure was also like that. Now I'm a little confused about what to do.
But now the project grade file seems different.
Yes, starting with the new Bumblebee update of Android Studio, the build.gradle (Project) file is changed. In order to be able to use Google Services, you have to add to your build.gradle (Project) file the following lines:
plugins {
id 'com.android.application' version '7.1.0' apply false
id 'com.android.library' version '7.1.0' apply false
id 'com.google.gms.google-services' version '4.3.0' apply false 👈
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And inside your build.gradle (Module) file, the following plugin IDs:
plugins {
id 'com.android.application'
id 'com.google.gms.google-services' 👈
}
In this way, your Firebase services will finally work.
P.S. Not 100% sure if the Firebase Assistant is updated with these new Android Studio changes.
Edit 2022-14-07:
Here is a repo that uses this new structure:
https://github.com/alexmamo/FirestoreCleanArchitectureApp
Edit:
There is nothing changed regarding the way you add dependencies in the build.gradle (Module) file. If for example, you want to add Firestore and Glide, please use:
dependencies {
//Regular dependecies
implementation platform("com.google.firebase:firebase-bom:29.0.4")
implementation "com.google.firebase:firebase-firestore"
implementation "com.github.bumptech.glide:glide:4.12.0"
}
Edit2:
With the new updates, you don't need to worry about adding any lines under the repositories { }. That was a requirement in the previous versions.
I've had the same problem just add in the gradle.build project
id 'com.google.gms.google-services' version '4.3.0' apply false
and then add in gradle.build module
dependencies {
//Regular dependecies
implementation platform("com.google.firebase:firebase-bom:30.4.0")
implementation "com.google.firebase:firebase-firestore"
}
You will find your classpath from https://console.firebase.google.com/
You will find something like this in the firebase(if you already got your classpath then you can ignore this section)
buildscript {
repositories {
// Make sure that you have the following two repositories
google() // Google's Maven repository
mavenCentral() // Maven Central repository
}
dependencies {
...
// Add the dependency for the Google services Gradle plugin
classpath 'com.google.gms:google-services:4.3.13'
}
}
allprojects {
...
repositories {
// Make sure that you have the following two repositories
google() // Google's Maven repository
mavenCentral() // Maven Central repository
}
}
just copy the classpath
1)In build.gradle(project)
before plugins make these changes-->
buildscript {
dependencies {
classpath 'com.google.gms:google-services:4.3.13'
}
}
plugins {
id 'com.android.application' version '7.2.2' apply false
id 'com.android.library' version '7.2.2' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
2)In build.gradle(module) add these lines in pulgins and dependencies section
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
}
dependencies {
implementation platform('com.google.firebase:firebase-bom:30.2.0')
implementation 'com.google.firebase:firebase-analytics'
}

Categories

Resources