Reputation: 2001
I have followed this link to integrate ads in my app. But it shows this error:
This is my build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.example.personal.numbermania"
minSdkVersion 10
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
debug
{
debuggable true
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.google.firebase:firebase-ads:9.6.0'
}
}
ads are not showing up in real device.please help me This is my error after i updated classpath error
Upvotes: 196
Views: 379225
Reputation: 27257
If you are having this issue in Dec 2024 onwards, comment out this line:
plugins {
...
//id 'com.google.gms.google-services'
}
and then change this:
dependencies {
classpath 'com.google.gms:google-services:4.4.2'
}
to this:
dependencies {
implementation 'com.google.gms:google-services:4.4.2'
}
Upvotes: 2
Reputation: 140
If this error occurred in flutter version 3.24.4
id 'com.google.gms.google-services' version '4.4.2' apply false
Add the above line in the /android/settings.gradle
It worked for me.
Upvotes: 1
Reputation: 336
After updating Flutter version, add these lines to your code.
In android/app/build.gradle:
plugins {
id "com.android.application"
id "kotlin-android"
id "org.jetbrains.kotlin.android"
id "dev.flutter.flutter-gradle-plugin"
id "com.google.gms.google-services"}
dependencies {
implementation(platform("org.jetbrains.kotlin:kotlin-bom:2.0.0"))
implementation(platform("com.google.firebase:firebase-bom:33.1.1"))
implementation("com.google.firebase:firebase-analytics")
implementation("com.google.firebase:firebase-auth")
implementation 'com.google.android.gms:play-services-maps:18.2.0'}
In android/settings.gradle:
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false
id "org.jetbrains.kotlin.android" version "2.0.0" apply false
id "com.google.gms.google-services" version "4.4.0" apply false}
Upvotes: 1
Reputation: 65
id("com.google.gms.google-services")
Use this instead of
id 'com.google.gms.google-services'
This is applicable and used for latest versions of android studio
Upvotes: 2
Reputation: 76699
Setting up Gradle plugins
in the root build.gradle
meanwhile works alike this:
plugins {
id "com.android.application" version "8.3.2" apply false
id "com.android.library" version "8.3.2" apply false
id "com.google.gms.google-services" version "4.4.1" apply false
}
Then they can be applied in a module:
plugins {
id "com.android.application"
id "com.google.gms.google-services"
}
Unless some Gradle plugin may depend on it, one can remove/skip the buildscript
block altogether, but it's still good for defining project-wide version numbers in buildscript.ext
:
buildscript {
ext {
agp_version = '8.3.2'
gms_version = '4.4.1'
}
}
plugins {
id 'com.android.application' version "$agp_version" apply false
id 'com.android.library' version "$agp_version" apply false
id "com.google.gms.google-services" version "$gms_version" apply false
}
Please note that meanwhile the suggested way to deal with version numbers is to maintain a version-catalog in file gradle/libs.versions.toml
; for example and the documentation: https://stackoverflow.com/a/78250599/549372
Upvotes: 94
Reputation: 513
If you using kts
then specify the version in build.gradle.kts
plugins {
id("com.google.gms.google-services") version "put_version_here"
}
Upvotes: 2
Reputation: 131
I have a very simple solution: Go to build.gradle(project) and in dependencies add following class path:
classpath 'com.google.gms:google-services:4.4.0'
Now make sure to add updated service if available >4.4.0 Build again. Done
Upvotes: 2
Reputation: 609
If you are using build-gradle.kt
add this
buildscript {
repositories {
google()
mavenCentral()
// Android Build Server
maven { url = uri("../nowinandroid-prebuilts/m2repository") }
}
dependencies {
classpath ("com.google.gms:google-services:4.4.0")
}
}
Upvotes: 1
Reputation: 2030
I initially had classpath 'com.google.gms.google-services:4.3.15'
and it was not working. It worked when I changed to classpath 'com.google.gms:google-services:4.3.15'
.
Upvotes: 1
Reputation: 627
The Google docs during the Android setup process didn't quite work for me. It seems like Google need to update their docs. The only solution that worked for me was:
build.gradle
file.dependencies {
classpath 'com.google.gms:google-services:4.3.14'
// ...
}
This plugin will allow to process the google-services.json
file and produce Android resources that can be used in your application's code. Also, it will allow to install dependencies for Firebase related libraries, which is going to be the next step.
build.gradle
file:apply plugin: 'com.google.gms.google-services'
Sources:
Upvotes: 7
Reputation: 506
In android bumblebee Just add this code on top in the build.gradle <Project .> file
buildscript {
dependencies {
classpath 'com.google.gms:google-services:4.3.10'
}
}
Now try to add plugin in build.gradle <app .> like this
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'com.google.gms.google-services'
}
Upvotes: 0
Reputation: 3515
Non of the answers above helped in my case, but following this tutorial thoroughly did. Maps SDK for Android / Set up an Android Studio project
Upvotes: 2
Reputation: 747
On upgrading to Android Studio 4.2.1, I was prompted to set dependency:
classpath 'com.google.gms:google-services:4.3.7'
However, this caused "Plugin with id 'com.google.gms.google-services' not found".
Leaving it as follows fixed the problem:
classpath 'com.google.gms:google-services:4.3.5'
EDIT:
This problem has now been fixed in:
classpath 'com.google.gms:google-services:4.3.8'
Upvotes: 10
Reputation: 446
Ended up on this thread while trying to integrate Firebase with a Flutter application. So, in case you are facing the same problem in Flutter, below steps solved the issue for me.
Disclaimer: first steps are the same as described in the documentation and every answer/tutorial found online. I am just mentioning them on a high level for the sake of keeping my answer consistent.
The actual step that is different and solved the issue is the last one.
repositories { google() jcenter() maven { url "https://maven.google.com" } } dependencies { classpath 'com.android.tools.build:gradle:3.5.0' classpath 'com.google.gms:google-services:4.3.4' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } allprojects { repositories { google() jcenter() maven { url "https://maven.google.com" } } }
apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" apply plugin: 'com.google.gms.google-services'
dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation platform('com.google.firebase:firebase-bom:26.3.0') implementation 'com.google.firebase:firebase-analytics' implementation 'com.google.firebase:firebase-messaging' testImplementation 'junit:junit:4.+' androidTestImplementation 'androidx.test.ext:junit:1.1.2' androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' }
You can find a working demo for this here https://gitlab.com/ecocupaegean/ecocupaegean/-/tree/master/, in order to run the app you just need to add your own google-services.json, and specify an API KEY for google maps geolocation API.
Upvotes: 3
Reputation: 41
In project's build.gradle add the following
classpath 'com.google.gms:google-services:4.3.3'
Upvotes: 1
Reputation: 1384
I'm not sure about you, but I spent about 30 minutes troubleshooting the same issue here, until I realized that the line for app/build.gradle is:
apply plugin: 'com.google.gms.google-services'
and not:
apply plugin: 'com.google.gms:google-services'
Eg: I had copied that line from a tutorial, but when specifying the apply plugin namespace, no colon (:
) is required. It's, in fact, a dot. (.
).
Hey... it's easy to miss.
Upvotes: 8
Reputation: 81
In the app build.gradle
dependency, you must add the following code
classpath 'com.google.gms:google-services:$last_version'
And then please check the Google Play Service SDK tools installing status.
Upvotes: 4
Reputation: 11254
Go To Setting > Android SDK > SDK Tools > Google Play Services
Upvotes: 12
Reputation: 331
Had the same problem.
adding this to my dependency didn't solve
classpath 'com.google.gms:google-services:3.0.0'
Adding this solved for me
classpath 'com.google.gms:google-services:+'
to the root build.gradle.
Upvotes: 23
Reputation: 813
I changed google-services classpath version from 4.2.0 to 3.0.0
classpath 'com.google.gms:google-services:3.0.0'
Then rebuild the project, Then strangely it suggested me to add firebase core to the project.
Then I added firebase core on the app(module)
implementation 'com.google.firebase:firebase-messaging:16.0.8'
Then the error disappeared magically.
Upvotes: 2
Reputation: 2154
simply add "classpath 'com.google.gms:google-services:3.0.0'" to android/build.gradle to look like this
buildscript {
repositories {
maven {
url "https://maven.google.com"
}
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
and also add "apply plugin: 'com.google.gms.google-services'" to the end of file in android/app/build.gradle to look like this
apply plugin: 'com.google.gms.google-services'
Upvotes: 14
Reputation: 2851
Add classpath com.google.gms:google-services:3.0.0
dependencies at project level build.gradle
Refer the sample block from project level build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
Upvotes: 67
Reputation: 2657
You can find the correct dependencies here apply changes to app.gradle and project.gradle and tell me about this, greetings!
Your apply plugin: 'com.google.gms.google-services' in app.gradle looks like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.example.personal.numbermania"
minSdkVersion 10
targetSdkVersion 24
versionCode 1
versionName "1.0"
multiDexEnabled true
}
dexOptions {
incremental true
javaMaxHeapSize "4g" //Here stablished how many cores you want to use your android studi 4g = 4 cores
}
buildTypes {
debug
{
debuggable true
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.google.firebase:firebase-ads:9.6.1'
compile 'com.google.firebase:firebase-core:9.6.1'
compile 'com.google.android.gms:play-services:9.6.1'
}
apply plugin: 'com.google.gms.google-services'
Add classpath to the project's gradle:
classpath 'com.google.gms:google-services:3.0.0'
Google play services library on SDK Manager:
Upvotes: 33
Reputation: 51
In build.gradle(Module:app) add this code
dependencies {
……..
compile 'com.google.android.gms:play-services:10.0.1’
……
}
If you still have a problem after that, then add this code in build.gradle(Module:app)
defaultConfig {
….
…...
multiDexEnabled true
}
dependencies {
…..
compile 'com.google.android.gms:play-services:10.0.1'
compile 'com.android.support:multidex:1.0.1'
}
Upvotes: 5
Reputation: 6761
Had the same problem.
Fixed by adding the dependency
classpath 'com.google.gms:google-services:3.0.0'
to the root build.gradle
.
https://firebase.google.com/docs/android/setup#manually_add_firebase
Upvotes: 265
Reputation: 2878
apply plugin: 'com.google.gms.google-services'
add above line at the bottom of your app gradle.build.
Upvotes: 3