I've checked this answer:
https://stackoverflow.com/a/34834772/13519865
It tells us to remove this line
apply plugin: 'com.google.gms.google-services'
Removing the line as asked completes the build, but I can't use Firebase (ofc!), it caused a new error, which tells me to add the line:
https://stackoverflow.com/a/40085096/13519865
So, I'm stuck in a loop here.
Related code sample added here https://github.com/Cyberavater/A.Reader
This issue started after updating the com.android.tools.build:gradle to version 7.3.0 and was fixed for me after updating the com.google.gms:google-services to version 4.3.14.
Edit: 2023-01-04
I have seen the same issue with the latest Android Studio Dolphin release, where you need to specify the Gradle version to be 7.3.1 and Google Services 4.3.14.
plugins {
id 'com.android.application' version '7.3.1' apply false
id 'com.android.library' version '7.3.1' apply false
}
dependencies {
classpath 'classpath "com.google.gms:google-services:4.3.14'
}
According to the new Chipmunk update of Android Studio, if you need to use Google Services, you have to add the following lines of code inside your build.gradle (Project) file:
plugins {
id 'com.android.application' version '7.3.1' apply false
id 'com.android.library' version '7.3.1' apply false
id 'com.google.gms.google-services' version '4.3.14' 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' 👈
}
change this line in >> android/build.gradle
classpath 'com.google.gms:google-services:4.3.10'
to
classpath 'com.google.gms:google-services:4.3.14'
Read this if Alex Mamo's answer does not solve the problem for you.
The new updates of Android Studio prioritize or prefer the settings.gradle file above build.gradle(project) for plugin management. There are two possible solutions.
Solution 1. Update your existing project as follows.
Update your settings.gradle
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
gradlePluginPortal()
jcenter()
maven {
url "https://plugins.gradle.org/m2/"}
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
gradlePluginPortal()
maven {
url "https://plugins.gradle.org/m2/"}
}
}
rootProject.name = "Your App Name"
include ':app'
Update your build.gradle(project). Use your Gradle version, this example uses version 7.3.0, and google-services: 4.3.14.
buildscript {
repositories {
mavenCentral()
gradlePluginPortal()
maven {
url "https://plugins.gradle.org/m2/"
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.3.0'
classpath 'com.google.gms:google-services:4.3.14'
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.14.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
plugins {
id 'com.android.application' version '7.3.0' apply false
id 'com.android.library' version '7.3.0' apply false
id 'com.google.gms.google-services' version '4.3.14' apply false
// other plugins in build.gradle(project)
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Add this to your build.gradle(app)
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
// other plugins
}
Solution 2. You can create a new project and move all your classes and XML into the new project.
I was facing the same issues but after updating the dependency the issues were resolved.
in my project level Gradle file previous it was as below:
dependencies {
classpath 'com.android.tools.build:gradle:7.3.1'
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'
classpath 'com.google.firebase:perf-plugin:1.4.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
after updating as below, It was working fine with me.
dependencies {
classpath 'com.android.tools.build:gradle:7.3.1'
classpath 'com.google.gms:google-services:4.3.14'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.2'
classpath 'com.google.firebase:perf-plugin:1.4.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Try with deleting .idea and .gradle folders from root of your app , an then from main app module ... If this doesn't work , then you must clone your project, making new one with same package name ... This is bug in Android Studio Dolphin , and I solved it with cloning with new project with same package name
First check your build.gradle(project) and paste these code below the plugins and also sync your project.
task clean(type: Delete) {
delete rootProject.buildDir 😊
}
I updated my kotlin version to 1.4.20 in project build.gradle file in Android Studio. But, i am not able sync my project. I am getting this error:
A problem occurred configuring root project 'Modules'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not find kotlin-scripting-compiler-embeddable-1.4.20.jar (org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:1.4.20).
Searched in the following locations:
https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-scripting-compiler-embeddable/1.4.20/kotlin-scripting-compiler-embeddable-1.4.20.jar
> Could not find kotlin-stdlib-common-1.4.20.jar (org.jetbrains.kotlin:kotlin-stdlib-common:1.4.20).
Searched in the following locations:
https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-common/1.4.20/kotlin-stdlib-common-1.4.20.jar
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
I also went to Tools->Kotlin->Configure Kotlin Plugin Updates and installed the latest kotlin. Still i am getting this error.
So, What could be the reason?
build.gradle (Modules)
buildscript {
ext {
kotlinVersion = "1.4.20"
gradleVersion = '4.0.0'
}
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:${gradleVersion}"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}"
classpath "org.jetbrains.kotlin:kotlin-allopen:${kotlinVersion}"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
build.gradle (:app)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply from: "$rootDir/gradle/local-aar.gradle"
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath "com.google.gms:google-services:${gmsLibVersion}"
}
}
apply plugin: 'com.google.gms.google-services'
//Rest of the code
I am using gradle and I am trying to add kotlin to my project. But when I am trying to add 'kotlin-android-extensions' plugin for gradle it fails to find it.
To use the plugin, you have to add it in your root level file:
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com'
}
}
ext.kotlin_version = '1.1.2-4'
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Try to add the following to your gradle.build file
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
after that you have to make some changes in your dependencies classpath like this.
buildscript {
ext.kotlin_version = '1.1.60'
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
and in dependencies compile make sure to add jre7 such that.
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
After doing all that rebuild the gradle and you are all done. This worked for me because i was facing the same problem you are now, and after this it's all done. Hope it works for you tooo....
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:+"
try this
I am getting “Plugin with id 'com.android.application' not found”. I have updated the gradle distribution version in gradle wrapper properties but to no avail. Do I need to write the build gradle dependencies somewhere?
You have to add in your top level file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
i'm trying to add Google analytics inside of the my app using this tutorial:
https://developers.google.com/analytics/devguides/collection/android/v4/
But i stucked on the problem, where to exactly put the line:
apply plugin: 'com.google.gms.google-services'
So my build.gradle top level file is looking like this:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.google.gms:google-services:1.3.0-beta1'
apply plugin: 'com.google.gms.google-services'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
But this is wrong. Where to put apply plugin exactly please?
Thanks for any help.
In andriod studio you have this kind of structure:
root
build.gradle
app
build.gradle
In the top-level build.gradle you have:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.google.gms:google-services:1.3.0-beta1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
In your app/build.gradle
apply plugin: 'com.google.gms.google-services'
//...
dependencies{
//.....
compile 'com.google.android.gms:play-services-analytics:7.3.0'
}
Should be inside of the object
allprojects
on top of the app build.grade
like this:
apply plugin: 'com.android.application'
apply plugin: 'com.android.databinding'