I am trying to get 'FCM' and 'GcmListenerService' working, i added the required dependencies to gradle files as shown below.
but when i tried to build the project, i received the below posted errors..
please let mek know how to fix it
build.gradle app:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':appcompat')
compile project(':securepreferences')
compile 'com.android.support:support-v4:25.2.0' // .0.1
compile 'com.google.android.gms:play-services:9.0.0'
compile 'com.github.chrisbanes.photoview:library:1.2.4'
compile 'com.google.code.gson:gson:2.7'
compile 'com.squareup:otto:1.3.8'
compile 'com.squareup.okhttp:okhttp:2.2.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.2.0' // 7.5'
compile 'com.squareup.picasso:picasso:2.4.0'
compile 'com.squareup.retrofit:retrofit:1.8.0'
compile files('app/libs/android-viewbadger.jar')
compile files('app/libs/iDappsImagesLib_v0.2.jar')
compile files('app/libs/iDappsToolsLib_v0.1.jar')
compile files('gradle/wrapper/gradle-wrapper.jar')
}
dependencies {
compile 'com.google.firebase:firebase-messaging:10.0.1'
}
apply plugin: 'com.google.gms.google-services'
build.grdle proj:
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.7' // 1.8?
classpath 'com.google.gms:google-services:9.0.0'
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
error:
Error:Could not find com.google.gms:google-services:9.0.0.
Searched in the following locations:
file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/google/gms/google-services/9.0.0/google-services-9.0.0.pom
file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/google/gms/google-services/9.0.0/google-services-9.0.0.jar
https://jcenter.bintray.com/com/google/gms/google-services/9.0.0/google-services-9.0.0.pom
https://jcenter.bintray.com/com/google/gms/google-services/9.0.0/google-services-9.0.0.jar
https://repo1.maven.org/maven2/com/google/gms/google-services/9.0.0/google-services-9.0.0.pom
https://repo1.maven.org/maven2/com/google/gms/google-services/9.0.0/google-services-9.0.0.jar
Required by:
project :
The last google-services version is 3.1.0, so edit your build.gradle project file as follows:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:3.1.0'
...
}
}
Then, in your build.gradle app file, you can use com.google.gms:google-services:9.0.0, but I think, actually the last version is 11.0.2, so I will recommend you to update
https://firebase.google.com/docs/android/setup
https://firebase.google.com/docs/android/setup#manually_add_firebase
Your app/build.gradle's dependencies looks fine, but make sure you have apply plugin: 'com.google.gms.google-services' at the root-bottom.
Your project/build.gradle does not. From docs:
buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:3.1.0'
}
}
Why do you have an extra classpath 'com.google.gms:google-services:9.0.0' in there?
Please review and double check your setup against the docs.
Related
I'm trying to add Firebase to my chat app in android studio, but all provided build.gradle plugins are not syncing.
I have tried some code below:
classpath 'com.google.gms:google-services:4.2.0' implementation 'com.google.firebase:firebase-core:16.0.7'
and then comes
ERROR: Could not find method implementation() for arguments
[com.google.firebase:firebase-core:16.0.7] on object of type
org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
I had the same error when adding Firebase into my Ionic app. Turns out I was putting the line implementation 'com.google.firebase:firebase-core:16.0.1' under the dependencies found within buildscript when this line should have been placed within the dependencies at the app-level (see below).
Put implementation 'com.google.firebase:firebase-core:16.0.1' here:
dependencies {
implementation fileTree(dir: 'libs', include: '*.jar')
implementation 'com.google.firebase:firebase-core:16.0.1'
// SUB-PROJECT DEPENDENCIES START
implementation(project(path: ":CordovaLib"))
compile "com.android.support:support-annotations:27.+"
compile "com.android.support:support-v4:24.1.1+"
compile "com.google.firebase:firebase-core:16.0.+"
compile "com.google.android.gms:play-services-analytics:11.0.1"
// SUB-PROJECT DEPENDENCIES END
}
not here:
buildscript {
repositories {
mavenCentral()
maven {
url "https://maven.google.com"
}
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
}
}
If it helps, I found the app-level dependencies section near the bottom of my project-level build.gradle file.
Good luck!
I was adding firebase to my project as documented in the official website.
In the 4th step it says to add compile 'com.google.firebase:firebase-core:16.0.0'.
But trying to synch gradle I would get errors:
and by trying to download them (install repository abd synch project) I would get this error:
here is my gradle dependencies:
dependencies {
implementation 'com.google.firebase:firebase-core:16.0.1'
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.google.android.gms:play-services-gcm:15.0.1'
compile 'com.google.android.gms:play-services-location:15.0.1'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:multidex:1.0.2'
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.google.firebase:firebase-auth:11.6.2'
compile 'com.google.android.gms:play-services-auth:15.0.1'
compile 'com.google.code.gson:gson:2.7'
compile('io.socket:socket.io-client:1.0.0') {
// excluding org.json which is provided by Android
exclude group: 'org.json', module: 'json'
}
compile 'com.onesignal:OneSignal:3.6.5'
compile 'com.android.volley:volley:1.0.0'
testCompile 'junit:junit:4.12'
}
this answer did not work either:
this
update
My project-level gradle:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
mavenCentral()
google()
}
}
Upgrade the following:
implementation 'com.google.firebase:firebase-auth:11.6.2'
into this:
implementation 'com.google.firebase:firebase-auth:16.0.2'
Add google service plugin version 4.0.1 and google() repo in top level gradle file:
buildscript {
// ...
dependencies {
// ...
classpath 'com.google.gms:google-services:4.0.1' // google-services plugin
}
}
allprojects {
// ...
repositories {
// ...
google() // Google's Maven repository
}
}
Use same versions of firebase services to avoid conflicts.
Refer https://firebase.google.com/docs/android/setup
To solve your problem.
Before you proceed, clean and rebuild your project.
Then at app/build.gradle,
add apply plugin: 'com.google.gms.google-services'
like the code snippet down below.
android {
// ...
}
dependencies {
// ...
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'
And make sure all the library used are as here.
Hope it helps!
Add firebase-core to your dependencies block:
implementation 'com.google.firebase:firebase-core:16.0.1'
The Firebase SDK release notes for the June 12 release explain:
Your app gradle file now has to explicitly list
com.google.firebase:firebase-core as a dependency for Firebase
services to work as expected.
It's also safer to list google() first in repository lists:
repositories {
google()
jcenter()
...
}
app level gradle
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
//compile 'com.android.support:support-v4:23.1.1'
//compile 'com.android.support:mediarouter-v7:23.1.1'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.google.android.gms:play-services-drive:10.0.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.google.android.gms:play-services-maps:10.0.0'
compile 'com.google.android.gms:play-services-location:10.0.1'
compile 'com.android.support:design:23.4.0'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
compile 'com.google.android.gms:play-services-ads:10.0.1'
}
apply plugin: 'com.google.gms.google-services'
when I remove apply ( plugin: 'com.google.gms.google-services' )there is no problem but after adding it I get (Error:Execution failed for task ':app:processDebugGoogleServices'.
Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 10.0.1.)
root level gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.google.gms:google-services:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.1.3-2'
ext.realm_version = '3.7.2'
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:3.1.0'
classpath "io.realm:realm-gradle-plugin:$realm_version"
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
}
}
allprojects {
repositories {
jcenter()
maven { url "https://maven.google.com" }
maven { url 'https://dl.bintray.com/jetbrains/anko' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
repositories {
mavenCentral()
}
My app/build.gradle
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android'
apply plugin: 'io.fabric'
apply plugin: 'realm-android'
realm {
syncEnabled = true;
}
repositories {
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
}
android {
compileSdkVersion 26
buildToolsVersion "25.0.3"
dexOptions {
jumboMode = true
}
defaultConfig {
applicationId "com.my.project"
minSdkVersion 15
targetSdkVersion 23
versionCode 54
versionName "1.3.54"
multiDexEnabled true
}
}
def AAVersion = '4.3.1'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:26.1.0'
compile('com.crashlytics.sdk.android:crashlytics:2.6.0#aar') {
transitive = true;
}
compile('com.digits.sdk.android:digits:1.11.0#aar') {
transitive = true;
}
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.volley:volley:1.0.0'
compile 'com.baoyz.swipemenulistview:library:1.3.0'
compile 'com.google.android.gms:play-services-gcm:11.0.4'
compile 'com.google.code.gson:gson:2.7'
compile 'com.miguelcatalan:materialsearchview:1.4.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.7.3'
compile 'com.squareup.okhttp:okhttp:2.7.3'
compile 'com.theartofdev.edmodo:android-image-cropper:2.2.5'
compile 'commons-codec:commons-codec:1.9'
compile 'commons-io:commons-io:2.4'
compile 'io.realm:android-adapters:2.0.0'
compile 'org.apache.commons:commons-lang3:3.4'
compile 'org.apache.httpcomponents:httpcore:4.4.4'
compile 'org.apache.httpcomponents:httpmime:4.3.6'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile 'us.feras.mdv:markdownview:1.1.0'
compile 'org.jetbrains.anko:anko-sdk15:0.9.1'
compile "org.androidannotations:androidannotations-api:$AAVersion"
// for annotaions
kapt "io.realm:realm-android-library:$realm_version"
kapt "org.androidannotations:androidannotations:$AAVersion"
compile 'com.firebaseui:firebase-ui-auth:2.3.0'
compile 'com.google.firebase:firebase-auth:11.0.4'
compile "com.android.support:design:26.1.0"
compile "com.android.support:customtabs:26.1.0"
compile "com.android.support:cardview-v7:26.1.0"
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
When I build I get error:
Error:Execution failed for task ':app:processDevGoogleServices'.
> File google-services.json is missing. The Google Services Plugin cannot function without it.
Searched Location:
com\my_project\app\src\dev\google-services.json
com\my_project\\app\google-services.json
OK.In Android Studio select menu: Tools->Friebase
Firebase-> Authentification
Click on Email and password authentification
Connect to your app to Firebase
and get error:
Could not parse the Android Application module
I've just resolve this problem.
I was upgrading the old GCM to FCM, and the Firebase Assistant shows the same error message as yours.
Solved by:
Go to Firebase console, in the Settings of my project, download google-servics.json to app/ folder. (Replace my old GCM's json file)
doing Add Firebase to your app again,
Then I can use the Firebase Assistans of AndroidStudio, again.
For me, the issue was classpath 'com.google.gms:google-services:4.3.0' was giving error, then I changed to classpath 'com.google.gms:google-services:4.2.0', resync'd Project with Gradle Files', then pressed Connect to firebase, :D
You might want to try 'Sync Project with Gradle Files'.
Sometimes I forget to sync the implementations after adding them to the gradle file.
Getting this error
Error:Execution failed for task ':app:compileDebugKotlin'.
> Compilation error. See log for more details
As soon as I add this line of code to the app
firebaseAuth = FirebaseAuth.getInstance()
Dependency is added to gradle app module
compile 'com.google.firebase:firebase-auth:10.0.1'
Any idea what's causing this error?
EDIT
: Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
class com.google.firebase.auth.FirebaseAuth, unresolved supertypes: com.google.android.gms.internal.zzbql
but I do have it
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'io.reactivex:rxkotlin:0.21.0'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.google.firebase:firebase-auth:10.0.1'
compile 'com.google.firebase:firebase-database:11.0.4'
compile 'com.google.dagger:dagger:2.4'
testCompile 'junit:junit:4.12'
kapt 'com.google.dagger:dagger-compiler:2.4'
provided 'org.glassfish:javax.annotation:10.0-b28'
}
**Project gradle**
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.1.2-5'
repositories {
maven { url 'https://maven.google.com' }
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven { url 'https://maven.google.com' }
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
**app gradle**
dependencies {
implementation 'com.google.firebase:firebase-auth:11.0.2'
implementation 'com.google.firebase:firebase-database:11.0.2'
implementation 'com.google.firebase:firebase-ads:11.0.2'
implementation 'com.google.android.gms:play-services-location:11.0.2'
}
**Please add this below dependencies and make sure firebase and play-services versions should be same.**
apply plugin: 'com.google.gms.google-services'