How to put Firebase RealtimeDatabase and FCM together - android

I might have some versions' issue I guess? I was using
implementation 'com.google.firebase:firebase-messaging:15.0.2'
Everything works fine, now I want to add RealtimeDatabase
The Assistant of Android Studio suggested :
implementation 'com.google.firebase:firebase-messaging:15.0.2'
implementation 'com.google.firebase:firebase-database:11.8.0'
Official Guide suggest
implementation 'com.google.firebase:firebase-messaging:15.0.2'
implementation 'com.google.firebase:firebase-database:16.0.1'
Both resulting : Please fix the version conflict either by updating the version of the google-services plugin ... or updating the version of com.google.android.gms to 15.0.2.
I know I might have to align their version, but I got
Could not find com.google.firebase:firebase-messaging:16.0.1.
or
Could not find com.google.firebase:firebase-database:15.0.2.
// If I use All official latest
implementation 'com.google.firebase:firebase-messaging:17.0.0'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
Could not find com.google.firebase:firebase-core:17.0.0.
So how can I put them together?
Official site :
Getting a "Could not find" error? Make sure you have added the Google maven respository to your root build.gradle
But I did. (Did I?) Here is my app.gradle
buildscript {
ext.kotlin_version = '1.2.30'
repositories {
google()
jcenter()
maven { url 'https://plugins.gradle.org/m2/' }
maven { url "https://maven.google.com" }
}
dependencies {
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.10.1'
classpath 'com.android.tools.build:gradle:3.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:3.1.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
ext {
roomVersion = '1.0.0'
archLifecycleVersion = '1.1.0'
}
task clean(type: Delete) {
delete rootProject.buildDir
}

Change this:
classpath 'com.google.gms:google-services:3.1.1'
into this:
classpath 'com.google.gms:google-services:4.0.1'
And use the following dependencies:
implementation 'com.google.firebase:firebase-messaging:17.0.0'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-core:16.0.1'
More info here: Firebase Release notes

Related

Plugin with id 'com.google.gms:google-services' not found [duplicate]

This question already has answers here:
Gradle sync failed: Plugin with id 'com.google.android.gms:play-services' not found
(3 answers)
Closed 3 years ago.
I'm trying to add Firebase to my Android app, while syncing the project I got:
Gradle sync failed: Plugin with id 'com.google.gms:google-services' not found.
I added the dependencies, google-services.json file in app root, also I added Maven repo in build.gradle top level.
1/ build.gradle top project file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.21'
repositories {
jcenter()
google()
}
allprojects {
// ...
repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
// ...
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.2.0' // Google Services plugin
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
ext {
buildToolsVersion = "25.0.2"
supportLibVersion = "25.3.1"
archRoomVersion = "1.0.0-alpha1"
}
}
2/ build.gradle // app level
dependencies {
implementation "android.arch.persistence.room:runtime:1.1.1"
implementation "android.arch.persistence.room:compiler:1.1.1"
implementation 'com.google.code.gson:gson:2.2.4'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
implementation 'io.reactivex.rxjava2:rxjava:2.1.17'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:support-vector-drawable:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation "android.arch.navigation:navigation-fragment-ktx:$navigationVersion"
implementation "android.arch.navigation:navigation-ui-ktx:$navigationVersion"
implementation 'com.google.firebase:firebase-core:16.0.1'
}
buildscript {
ext {
navigationVersion = '1.0.0-alpha09'
}
}
apply plugin: 'com.google.gms:google-services' // Google Play services Gradle plugin
Any idea what should I do?
The apply plugin is wrong. Should be:
apply plugin: 'com.google.gms.google-services'
Notice the . between com.google.gms and google-services.
Also, just in case, google() should go before jcenter().

"Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'."Warning keeps coming up again and again

So I am posting this after much research:
Android Studio build.gradle warning message
Still getting warning : Configuration 'compile' is obsolete and has been replaced with 'implementation'
As many of the solutions suggested,I upgraded my google-services version to 3.2.0.
Still the warning is coming up.
N.B. My project is using a lot of libraries:
Here is project level build.gradle:
buildscript {
repositories {
google()
jcenter()
maven { url 'https://maven.fabric.io/public' }
maven {
url 'https://maven.google.com'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.8.3'
//classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'com.google.gms:google-services:3.2.0'
classpath 'io.fabric.tools:gradle:1.22.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
maven { url 'https://maven.fabric.io/public' }
maven {
url 'https://maven.google.com'
}
}
}
Here are all the libraries in app level build.gradle
dependencies {
implementation "com.android.support:appcompat-v7:$SUPPORT_LIBRARY_VERSION"
implementation "com.android.support:cardview-v7:$SUPPORT_LIBRARY_VERSION"
implementation "com.android.support:design:$SUPPORT_LIBRARY_VERSION"
implementation "com.android.support:gridlayout-v7:$SUPPORT_LIBRARY_VERSION"
implementation "com.android.support:support-v4:$SUPPORT_LIBRARY_VERSION"
implementation "com.android.support:recyclerview-v7:$SUPPORT_LIBRARY_VERSION"
implementation "com.android.support:support-v13:$SUPPORT_LIBRARY_VERSION"
implementation "com.android.support:customtabs:$SUPPORT_LIBRARY_VERSION"
implementation "com.android.support:multidex:$MULTIDEX_VERSION"
implementation("com.bottlerocketstudios:barcode:$BARCODE_VERSION#aar") {
transitive = true;
}
implementation "com.bottlerocketstudios:javalockboxlib:$JAVALOCKBOXLIB_VERSION"
implementation "com.bottlerocketstudios:vault:$VAULT_VERSION"
implementation "com.github.bumptech.glide:glide:$GLIDE_VERSION"
implementation "com.github.bumptech.glide:okhttp3-integration:$GLIDE_OKHTTP_VERSION#aar"
implementation "com.squareup.okhttp3:logging-interceptor:$OKHTTP_LOGGER_VERSION"
implementation "com.facebook.android:facebook-android-sdk:$FACEBOOK_SDK_VERSION"
implementation "com.google.android.gms:play-services-auth:$PLAY_SERVICES_VERSION"
implementation "com.google.android.gms:play-services-gcm:$PLAY_SERVICES_VERSION"
implementation "com.google.android.gms:play-services-maps:$PLAY_SERVICES_VERSION"
implementation "com.google.android.gms:play-services-location:$PLAY_SERVICES_VERSION"
implementation "com.jakewharton:butterknife:$BUTTERKNIFE_VERSION"
implementation "com.jakewharton.rxbinding:rxbinding:$RX_BINDING_VERSION"
implementation "com.jakewharton.rxbinding:rxbinding-support-v4:$RX_BINDING_VERSION"
implementation "com.jakewharton.rxbinding:rxbinding-appcompat-v7:$RX_BINDING_VERSION"
implementation "com.jakewharton.rxbinding:rxbinding-design:$RX_BINDING_VERSION"
implementation "com.jakewharton.rxbinding:rxbinding-recyclerview-v7:$RX_BINDING_VERSION"
implementation "com.jakewharton.threetenabp:threetenabp:$THREETENABP_VERSION"
implementation "com.jakewharton.timber:timber:$TIMBER_VERSION"
implementation "com.jakewharton:process-phoenix:$PROCESS_PHEONIX_VERSION"
annotationProcessor "com.squareup.dagger:dagger-compiler:$DAGGER_VERSION"
implementation "com.squareup.dagger:dagger:$DAGGER_VERSION"
implementation "com.squareup.retrofit2:retrofit:$RETROFIT_VERSION"
implementation "com.squareup.retrofit2:adapter-rxjava:$RETROFIT_VERSION"
implementation "com.f2prateek.rx.preferences:rx-preferences:$RX_PREFERENCES_VERSION"
implementation "com.trello:rxlifecycle:$RX_LIFECYCLE_VERSION"
implementation "com.trello:rxlifecycle-components:$RX_LIFECYCLE_VERSION"
implementation "io.reactivex:rxjava:$RX_JAVA_VERSION"
implementation "io.reactivex:rxandroid:$RX_ANDROID_VERSION"
implementation "pl.charmas.android:android-reactive-location:$REACTIVE_LOCATION_VERSION#aar"
implementation("com.crashlytics.sdk.android:crashlytics:$CRASHLYTICS_VERSION#aar") {
transitive = true;
}
implementation "com.contentful.java:java-sdk:$CONTENTFUL_JAVA_SDK_VERSION"
implementation "uk.co.chrisjenx:calligraphy:$CALLIGRAPHY_VERSION"
implementation "com.flurry.android:analytics:$FLURRY_ANALYTICS_VERSION"
implementation 'org.jsoup:jsoup:1.11.1'
testImplementation "junit:junit:$JUNIT_VERSION"
}
Here are some important library version I am using :
OKHTTP_VERSION=3.8.1
RX_PREFERENCES_VERSION=1.0.0
PLAY_SERVICES_VERSION=15.0.1
BARCODE_VERSION=1.0.3
CONTENTFUL_JAVA_SDK_VERSION=7.5.0
BRFONTVIEW_VERSION=1.0.0
JUNIT_VERSION=4.12
BUTTERKNIFE_VERSION=7.0.1
DAGGER_VERSION=1.2.2
RX_ANDROID_VERSION=1.0.1
RX_JAVA_VERSION=1.0.14
JAVALOCKBOXLIB_VERSION=1.0.0
RX_BINDING_VERSION=0.3.0
CALLIGRAPHY_VERSION=2.1.0
SUPPORT_LIBRARY_VERSION=28.0.0-beta01
RX_LIFECYCLE_VERSION=0.2.0
REACTIVE_LOCATION_VERSION=0.8
RETROFIT_VERSION=2.3.0
CRASHLYTICS_VERSION=2.6.2
FACEBOOK_SDK_VERSION=4.23.0
The warning I am getting:
Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
Configuration 'debugCompile' is obsolete and has been replaced with 'debugImplementation' and 'debugApi'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
Any idea which one is causing the problem.
Just replace:
compile with implementation
testCompile with testImplementation
debugCompile with debugImplementation
androidTestCompile with androidTestImplementation
compileOnly is still valid. It was added in 3.0 to replace provided and not compile.
Changes with Gradle 3.0 is officially announced at GoogleIO17.
The compile configuration is now deprecated and should be replaced by implementation or api
Check out Gradle Documentation here
Warning you are getting is due to the libraries you have imported are you using compile keyword in the gardle.
The problem is with jakewharton hugo plugin which I was using in the app
classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'
Relevant link:
https://github.com/JakeWharton/hugo/issues/156
With the hot key "CTRL + Shift + F" try to search for "compile" keyword.If there is no modification left, please go to file -> Invalidate Caches/Restart.These error messages will be gone.
just replace compile-->implementation in app module, except compileSdkVersion in app module
The solution is to upgrade 'com.google.gms:google-services:3.1.0' to 'com.google.gms:google-services:4.0.1'

Update firebase 11 dependency on Android Gradle

I have the follow app/build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
...
minSdkVersion 19
targetSdkVersion 27
...
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
useLibrary 'org.apache.http.legacy'
}
dependencies {
implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.google.firebase:firebase-messaging:11.8.0'
implementation 'com.google.firebase:firebase-core:11.8.0'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.github.IntruderShanky:scatter-piechart:1.0.0'
implementation 'com.etsy.android.grid:library:1.0.5'
implementation 'com.journeyapps:zxing-android-embedded:3.6.0'
implementation 'com.google.zxing:core:3.3.0'
testImplementation 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
And follow project/build.gralde
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:3.2.1'
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://jitpack.io"
}
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
When I'm hovering mouse above firebase implementations I get the follow warnings
implementation 'com.google.firebase:firebase-messaging:11.8.0' show me
A newer version of com.google.firebase:firebase-messaging than 11.8.0
is available: 17.1.0
and implementation 'com.google.firebase:firebase-core:11.8.0' show me
A newer version of com.google.firebase:firebase-core than 11.8.0
is available: 16.0.1
Then I do the sugestion and update my implementation to available version as follow
implementation 'com.google.firebase:firebase-messaging:17.1.0'
implementation 'com.google.firebase:firebase-core:16.0.1'
and sync my project. But the project show me the follow errors
Failed to resolve: play-services-base Open File
Failed to resolve: play-services-tasks Open File
Failed to resolve: play-services-stats Open File
Failed to resolve: play-services-ads-identifier Open File
Failed to resolve: play-services-basement Open File
I'm trying solve it for a long time and nothing work. Please, help me to solve it!
In the top level gradle file add the following:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:4.0.2'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Add the google() repo before jcenter() and use the latest google service plugin version 4.0.2
https://bintray.com/android/android-tools/com.google.gms.google-services/
Make sure you are connected to a good network
Try adding Google maven repository into app's build.gradle file:
repositories {
maven { url "https://maven.google.com" }
}
If step 1 won't work, remove gradle from your project root folder and rebuild your project again.
Try another
Goto >file -> other settings -> Under build, execution, and deployment
-> you will see Gradle. uncheck the checkbox offline work

firebase-core:12.0.1 not found

I have created a firebase project and it says I have to modify the core version to 12 according to the picture
The default code is 9.6.1. So, I changed that number to 12.0.1
compile 'com.google.firebase:firebase-core:12.0.1'
However, the sync failed with the following error
Failed to resolve: com.google.firebase:firebase-core:12.0.1
What should I do?
Update the gms plugin:
classpath 'com.google.gms:google-services:4.0.0' // google-services plugin
and the firebase lib:
implementation 'com.google.firebase:firebase-core:16.0.0'
Also add google maven to your build.gradle file:
allprojects {
// ...
repositories {
// ...
maven {
url "https://maven.google.com" // Google's Maven repository
}
jcenter()
maven { url "https://jitpack.io" }
}
}
com.google.firebase:firebase-core:12.0.1 is old version already.
You can try version 15.0.0 or as Levi Albuquerque said 16.0.0
However just to remind you that if you implement more than one same kind of library, they should be always in the same version to avoid any syncing error.
Example
implementation 'com.google.firebase:firebase-auth:15.0.0'
implementation 'com.google.firebase:firebase-storage:15.0.0'
implementation 'com.google.firebase:firebase-database:15.0.0'
All are same version 15.0.0
You need to add the google() maven inside your allProjects block in your project build.gradle like this:
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
...
}
}
repositories {
...
}
// You need to add the google maven in this block.
allprojects {
repositories {
jcenter()
google()
}
}
For avoid further errors in grandle beacause of a bug try to use:
classpath 'com.google.gms:google-services:3.2.1'
And for firebase use what you need from below:
implementation 'com.google.firebase:firebase-core:15.0.2'
implementation 'com.google.firebase:firebase-ads:15.0.1'
implementation 'com.google.firebase:firebase-analytics:15.0.2'
implementation 'com.google.firebase:firebase-appindexing:15.0.1'
implementation 'com.google.firebase:firebase-auth:15.1.0'
implementation 'com.google.firebase:firebase-firestore:16.0.0'
implementation 'com.google.firebase:firebase-functions:15.0.0'
implementation 'com.google.firebase:firebase-messaging:15.0.2'
implementation 'com.google.firebase:firebase-storage:15.0.2'
implementation 'com.google.firebase:firebase-crash:15.0.2'
implementation 'com.google.firebase:firebase-invites:15.0.1'
implementation 'com.google.firebase:firebase-perf:15.2.0'
implementation 'com.google.firebase:firebase-database:15.0.1'
implementation 'com.google.firebase:firebase-config:15.0.2'
If you using gogle play-services in your grandle set version to 15.0.0 like below example:
implementation 'com.google.android.gms:play-services-location:15.0.0'
implementation 'com.google.android.gms:play-services-maps:15.0.0'
implementation 'com.google.android.gms:play-services-places:15.0.0'
implementation 'com.google.android.gms:play-services-gcm:15.0.0'
I hope this will help you =)

Android Studio Failed to resolve: support-core-utils

After upgrading support library version to 27.1.1 when i sync the project i face with below error:
Failed to resolve: support-core-utils
Any idea?
here is my project level build file:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
and app level build file:
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
I solved this by setting
google() as first entry in allprojects/repositories in top level build.gradle
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io"
}
}
}
as per behavior changes in android-Gradle plugin (v3.2.0 September 2018) you need to keep the google repository as the first entry
buildscript {
repositories {
google() // here
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
}
}
allprojects {
repositories {
google() // and here
jcenter()
}
android-Gradle plugin release note
I have same problem and i changed to successful.
Added maven { url 'https://maven.google.com' } as first entry in allprojects/repositories in top level build.gradle
In my case , it was because of a library dependency and I solved by excluding support-core-utils from that library :
implementation ('com.github.chrisbanes:PhotoView:2.0.0'){
exclude module: 'support-core-utils'
}
I had the same problem with AppCompat library with version 28.0.0. I fixed it by using 28.0.0-alpha1. None of answers helped me.
Android studio 3.1.4
Target and compile sdk 28.
At the time the library was not really stable. support-core-utils is a part of android-support-v4, so if you still have a problem with that try adding
implementation 'com.android.support:support-v4:27.1.1'
to the dependencies.
do you add implementation 'com.android.support:design:XX.X.X', implementation 'com.android.support:support-v4:XX.X.X' ?
when I saw "duplicate value for resource" message I just had implementation 'com.android.support:appcompat-v7:28.0.0'
and I added implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-v4:28.0.0' and worked it !
Remove mavenCentral() from repositories script in project level if there.

Categories

Resources