import lottie to gradle - android

I want to add lottie dependency in my project.
this is the way that lottie document recommends
implementation "com.airbnb.android:lottie-compose:$lottieVersion"
allprojects {
repositories {
...
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}}
here is my gradle
buildscript {
ext {
compose_version = '1.1.1'
lottie_version = '0.5.4-SNAPSHOT'
}}
plugins {
id 'com.android.application' version '7.1.1' apply false
id 'com.android.library' version '7.1.1' apply false
id 'org.jetbrains.kotlin.android' version '1.6.10' apply false}
task clean(type: Delete) {
delete rootProject.buildDir}
as you can see there is no allProjects in my gradle.
how can I add Maven repository?

Go to your build.gradle module and inside dependencies section add
implementation "com.airbnb.android:lottie-compose:$lottieVersion"
Now go in settings.gradle and inside dependencyResolutionManagement -> repositories add this
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }

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'
}

build.gradle dont look properly (i think)?

// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.3.0' apply false
id 'com.android.library' version '7.3.0' apply false
id 'org.jetbrains.kotlin.android' version '1.7.10' apply false
}
this is only what i see in my build.gradle project. Im trying add this code (to get some custom toast cause the toast.view is deprecated):
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
but i cant see allprojects{} and the rest of things that should be there
There are different ways of defining repositories in Gradle. Recently, projects created in the Android Studio wizard no longer include an allProjects block in build.gradle. They configure the dependency repositories in a dependencyResolutionManagement block in the settings.gradle file. For example:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}

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'
}

Apply Firebase to Android Studio Project version Bumblebee

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
}
}

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'
}

Categories

Resources