cloud messaging and android - android

I am trying to implement google cloud messaging and push notifications on my android app
I am following official google tutorial , I am using android studio
https://developers.google.com/cloud-messaging/android/client
and I am getting this error
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.transform.api.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 2
here is my build.gradle
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/notice.txt'
}
compileSdkVersion 22
buildToolsVersion "23.0.0 rc2"
defaultConfig {
applicationId "com.myapp.example"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets.main {
jniLibs.srcDir 'libs'
jni.srcDirs = [] //disable automatic ndk-build call
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services:8.1.0'
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'org.java-websocket:Java-WebSocket:1.3.0'
compile 'com.github.nkzawa:socket.io-client:0.3.0'
compile 'rongi.rotate-layout:rotate-layout:1.0.1'
compile 'com.vdurmont:emoji-java:2.0.1'
compile 'commons-lang:commons-lang:2.5'
compile 'com.github.javadev:underscore:1.6'
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
compile 'org.florescu.android.rangeseekbar:rangeseekbar-library:0.2.0'
compile 'com.beardedhen:androidbootstrap:1.1.1'
compile 'com.mcxiaoke.volley:library:1.0.18'
compile 'com.reginald.swiperefresh:library:1.1.1'
compile 'com.makeramen:roundedimageview:2.2.0'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.github.d-max:spots-dialog:0.4#aar'
compile 'cn.pedant.sweetalert:library:1.3'
compile 'com.jakewharton:butterknife:6.1.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'in.srain.cube:grid-view-with-header-footer:1.0.12'
compile 'com.vstechlab.easyfonts:easyfonts:1.0.0'
}
also here is my project build.gradle file
// 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.2.3'
classpath 'com.google.gms:google-services:1.4.0-beta3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}

After some-days and nightmares, Finally I can defeat the problem and believe it could be of help to others.
Because of my massive coded project, test and checking each advice takes about 5 minutes of my system to build. I examined almost all of SO community suggestions and I wanna conclude them here:
This is most likely a problem with the dependencies you have listed in your build.gradle file for you app.
Things I do not recommend:
Unless you have an absolute need to enable multiDex in your
build.gradle DO NOT DO IT, this is just stepping over the
underlying problem in your app and not getting to the root of it. You
are also unnecessarily increasing the size of your apk, and there
could be unexpected crashes when there is a conflicting method in your
dex file.
Things to look out for:
Check all your dependencies in your build.gradle file if you have any
duplication. Are you referencing a dependency that also includes a
dependency you have already included? For example, if your including
appcompat-v7 there is no need to include appcompat-v4 since v7
includes all features from v4.
My Issue: GOOGLE PLAY SERVICES >> causing my app to exceed method limit in my dex file.
If you do not need all the google play services library dependencies DO NOT INCLUDE this line in your build.gradle compile 'com.google.android.gms:play-services:8.3.0' and instead just use what you need!! also check if your can build correctly with lower versions of the dependency.
Google has a comprehensive list of the libraries for selectively compiling here
With all that said you probably only need to include this one line in gradle for your Google Analytics:
dependencies{
compile 'com.google.android.gms:play-services-plus:8.3.0'
}
Well Done!

take a look in your gradle console and check the exact error
i just had the same problem. i solved it with:
Clean the project (at first, gradle had a error because of multiple classes included)
only include the service you really needed from play.
https://developers.google.com/android/guides/setup#split

Add one more file in your dependency list
compile 'com.android.support:multidex:1.0.0'
and add following to your defaultconfig
defaultConfig {
//your stuff
multiDexEnabled true
}

Related

Unable to merge dex when a module is imported

I know there are many questions on this, but I tried the solutions of most of them and neither of them worked.
I have an app in which I have imported a module. When I try to run the app, I am getting Unable to merge dex exception.
build.gradle (app module)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.meditab.imspatient"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2' // Constraint layout
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" // Kotlin
// Support libraries
implementation "com.android.support:appcompat-v7:$appcompat_version"
implementation "com.android.support:support-v4:$appcompat_version"
compile project(path: ':commonutils')
}
build.gradel (imported module)
apply plugin: 'com.android.library'
android {
compileSdkVersion 27
buildToolsVersion '27.0.2'
defaultConfig {
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'org.jetbrains:annotations-java5:15.0'
compile 'com.jakewharton:butterknife:8.8.1'
// Support libraries
compile "com.android.support:appcompat-v7:$appcompat_version"
compile "com.android.support:design:$appcompat_version"
// Rx related libraries
compile 'io.reactivex:rxjava:1.1.1'
compile 'io.reactivex:rxandroid:1.1.0'
//compile 'com.netflix.rxjava:rxjava-core:0.+'
// Networking related libraries
compile 'com.squareup.okhttp3:logging-interceptor:3.8.1'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-jackson:2.0.2'
compile 'com.squareup.retrofit2:adapter-rxjava:2.0.2'
compile 'com.fasterxml.jackson.core:jackson-databind:2.7.2'
compile 'com.google.firebase:firebase-core:11.8.0'
compile 'com.google.firebase:firebase-messaging:11.8.0'
compile 'com.google.android.gms:play-services-base:11.8.0'
compile 'com.google.android.gms:play-services-location:11.8.0'
compile 'com.estimote:sdk:0.10.+#aar'
}
build.gradle (project level)
buildscript {
ext.kotlin_version = '1.2.21'
ext.appcompat_version = '27.0.2'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// Needed for the common utils module
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I have tried deleting the .gradle folder, cleaning the project and rebuilding it. Nothing works. I also tried using implementation instead of compile in the build.gradle of the imported module.
Any help will be appreciated.
Thanks in advance.
It seems that 2 libraries you're declaring a dependency on are causing duplicate entries.
The problem is that you can't have the exact same class or annotation declared by 2 different libraries. If they were different versions of the same library probably the one with the highest version would be picked, but if they are completely different libraries, there is no way to tell which implementation should be included in the dex file.
The first one is:
'com.netflix.rxjava:rxjava-core:0.+'
Why would you use this? You have already defined a dependency on RxJava ('io.reactivex:rxjava:1.1.1') and they probably have many classes in common, the first that comes to my mind and that I checked is rx.Observable. The last update for that repo is Novermber 2014, more than 3 years ago. Besides conflicts, this fact alone should be a very good reason not to use it.
The second problem is:
'org.jetbrains:annotations-java5:15.0'
I imagine that you're importing this in order to get org.jetbrains.annotations.Nullable, this is already available in your project because Kotlin stdlib has a dependncy on org.jetbrains:annotations that also declares it. Hence the conflict.
Remove these 2 dependencies, you most likely don't actually need them anyway, and the project compiles.
I'm not 100 percent sure but I think you need to enable multidex in your app. Check this link : Enable Multidex
Just trying to help.
In my previous project which has multiple modules If I enable Proguard I was getting the same error.
That error frustrating and In my case I solved problem after inspecting
the project dependency graph(Using gradle to find dependency tree may help you while finding dependencies)
Play service's different version was causing in my case

Projects created at console.firebase.google.com must use the new Firebase Authentication SDKx available from firebase.google.com/dosc/auth

I am trying to enable GoogleSignIn for my android app and trying to run this code. I have created the json file from firebase console and pasted it in app. Enabled the google login from firebase but after running app on my phone it gives me error.
firebaseError: Projects created at console.firebase.google.com must use the new Firebase Authentication SDKx available from firebase.google.com/dosc/auth
Similar threads said to remove firebase client dependency but if I remove it I have compilation error. I also have tried to add latest dependency from the docs but no luck.
my gradle file
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
apply plugin: 'com.android.application'
repositories {
mavenCentral()
}
android {
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
defaultConfig {
minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION)
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE-FIREBASE.txt'
}
}
dependencies {
compile 'com.firebase:firebase-client-android:2.0.3+'
compile 'com.android.support:appcompat-v7:20.0.0'
compile 'com.google.android.gms:play-services:5.0.89'
compile 'org.twitter4j:twitter4j-core:4.0.2'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
}
What am I missing? What dependency I have to add other than firebase -client because if I add the latest the code still doesnt work.
Edit: After removing
compile 'com.firebase:firebase-client-android:2.0.3+'
compile 'com.google.android.gms:play-services:5.0.89'
And adding
compile 'com.google.firebase:firebase-auth:10.2.0'
compile 'com.google.android.gms:play-services-auth:10.2.0'
So my dependency looks like this
dependencies {
compile 'com.google.firebase:firebase-auth:10.2.0'
compile 'com.google.android.gms:play-services-auth:10.2.0'
compile 'com.android.support:appcompat-v7:20.0.0'
compile 'org.twitter4j:twitter4j-core:4.0.2'
compile 'com.facebook.android:facebook-android-sdk:4.1.0'
}
But for Above dependency now I have compilation issues in my code like.
For import com.firebase.client.Firebase; Cannot find the symbol client
import com.google.android.gms.plus.Plus; Cannot find the symbol plus
I have just created new project from link. It 's really easy to follow and sign in. Firebase did all work. You can discover the link below to know which configuration you missed.
Link to test sing in Google project

duplicate entry error after adding google services

I wanted to add firebase to one of my app. I integrated firebase according to firebase offical documents. but when I tried to "run" app. it gives me this warning
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzc.class
I removed all the firebase coding & removed it from gradle file. but error still exist untill I remove this line
apply plugin: 'com.google.gms.google-services'
but unfortunately I need google services to work with firebase. here is my app gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
applicationId ""
minSdkVersion 19
targetSdkVersion 22
versionCode 15
versionName "2.01"
multiDexEnabled true
}
dexOptions {
preDexLibraries = false
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile files('libs/main.jar')
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:cardview-v7:23.0.+'
compile 'com.android.support:recyclerview-v7:23.0.+'
compile 'com.squareup.picasso:picasso:2.5.0'
compile 'com.commit451:NativeStackBlur:1.0.1'
compile 'com.google.firebase:firebase-analytics:9.0.0'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.facebook.android:audience-network-sdk:4.11.0'
}
apply plugin: 'com.google.gms.google-services'
here is my project gradle file
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
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
}
}
allprojects {
repositories {
jcenter()
}
}
The problem was with Facebook Audience network. once I excluded google services it worked fine. If anyone having same problem change your audience network dependency like this
compile ('com.facebook.android:audience-network-sdk:4.11.0'){
exclude group: 'com.google.android.gms'
}
Add these dependencies:
compile 'com.google.android.gms:play-services-location:11.0.4'
compile 'com.google.android.gms:play-services-maps:11.0.4'
compile 'com.google.android.gms:play-services-gcm:11.0.4'
compile 'com.google.android.gms:play-services-places:11.0.4'
Add
android{
....
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
to your app's gradle file.
Add Firebase related dependencies
And Firebase related dependencies under dependencies in the same build.gradle file.
dependencies {
compile 'com.google.firebase:firebase-core:9.2.0' // this line must be included to integrate with Firebase
compile 'com.google.firebase:firebase-messaging:9.2.0' // this line must be included to use FCM
}
Update services using com.google.android.gms:play-services
If you add Firebase into an existing project which uses any function of gms:play-services, such as gps location,
you have to update their versions, too. Upon writing this tutorial, 9.2.0 works well. If you get compilation problems, you need to check find out the correct version number.
compile 'com.google.android.gms:play-services-location:9.2.0'
compile 'com.google.android.gms:play-services-places:9.2.0'
Source:
https://www.codementor.io/flame3/send-push-notifications-to-android-with-firebase-du10860kb

Android gradle problems(Current 2.4 Required 2.8) Android Studio

Im having a problems when trying to implement gcm. When I try to sync gradle files this error appears:
Warning:Gradle version 2.8 is required. Current version is 2.4. If using the gradle wrapper, try editing the distributionUrl in D:\MyProjects\Android\Enjoy\gradle\wrapper\gradle-wrapper.properties to gradle-2.8-all.zip
Tried to go to wrapper and change it to 2.8, but its still not working.
Here is my app build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "enjoy.enjoyprague_restaurants_bars"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
dexOptions {
javaMaxHeapSize "4g"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
// android libraries activity, design
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
// application
compile 'com.android.support:multidex:1.0.1'
// volley for handlers
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.google.code.gson:gson:2.4'
// picasso
compile 'com.squareup.picasso:picasso:2.5.2'
// simple xml
compile('org.simpleframework:simple-xml:2.7.1') {
exclude group: 'stax', module: 'stax-api'
exclude group: 'xpp3', module: 'xpp3'
}
// floating action menu
compile 'com.oguzdev:CircularFloatingActionMenu:1.0.2'
// Google Map api
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.maps.android:android-maps-utils:0.4'
}
//google gcm sender
apply plugin: 'com.google.gms.google-services'
and top level build gradle:
// 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:2.0.0-alpha3'
classpath 'com.google.gms:google-services:2.0.0-alpha3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven { url "http://dl.bintray.com/populov/maven" }
mavenCentral()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Open gradle folder in your project directory, and change gradle wrapper properties file. (you can find that last line indicating the path to gradle used in build). You may find it incorrect (e.g. http\://) fix it to (http://)
Ok, so, Android Studio is very buggy. Now, what you need to do is go to this question and do exactly as they said there. Take it to offline and that stuff. It will work, guaranteed.
https://stackoverflow.com/a/21996772/4458300
Use Graddle Wrapper
1)
Check distributionUrl and see if it is specified as gradle-2.8.zip at the Gradle-wrapper properties file within the Android project.
Project/gradle/wrapper/gradle-wrapper.properties
Run Gradle Wrapper at the top level of the project
Unix:
./gradlew wrapper
Windows:
gradlew.bat wrapper
Build with Gradle Wrapper.
Unix:
./gradlew build
Windows:
gradlew.bat build
Find in your project's structure in Android Studio this file
Open gradle-wrapper.properties and change this line:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
with
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
It should work

Failed to resolve: com.firebase:firebase-client-android:2.3.1

I am working on the Sample in the below blog
https://www.firebase.com/blog/2015-10-01-firebase-android-app-engine-tutorial.html
The projects fails to compile after adding the dependency
compile 'com.firebase:firebase-client-android:2.3.1'
Other dependencies compile without any issue.
'com.android.support:appcompat-v7:23.0.1'
'compile 'com.android.support:design:23.0.1'
Where am I going wrong ?
here is my module build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.tri.todoapp"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.firebase:firebase-client-android:2.4.0'
}
Top-level gradle
// 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'
// 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
}
The project fails to compile because version 2.3 doesn't exists. You should use 2.3.1:
compile 'com.firebase:firebase-client-android:2.3.1'
or the newest 2.4.0:
compile 'com.firebase:firebase-client-android:2.4.0'
You can find more information here:
https://www.firebase.com/docs/android/quickstart.html
We are talking about Google api versions without mentioning Google Repository version.
The actual problem here is that your Google Repository doesn't "know" about the firebase version you all were trying to use.
I got same error while following the official firebase documentation
My app-level build.gradle file looked like this:
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
// ...
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.firebase:firebase-messaging:10.2.1'
}
apply plugin: 'com.google.gms.google-services'
My Google Repository version was 44
You can check yours in
SDK Manager>Android SDK> SDK Tools (tab)
Latest version is 46 (at the time of writing this)
I updated to latest Google Repository version and the problem was solved!
You can update by checking "Google Repository" under SDK Tools tab and click "Apply" to update Google Repository to latest version
If you do not wish to update your Google Repository version, you can still resolve the issue by lowering your firebase api version slighlty.
For my case, changing app-level build.gradle file to the following also fixes my problem:
apply plugin: 'com.android.application'
android {
// ...
}
dependencies {
// ...
compile 'com.google.firebase:firebase-core:10.2.0'
compile 'com.google.firebase:firebase-messaging:10.2.0'
}
apply plugin: 'com.google.gms.google-services'
firebase version has been lowered to version 10.2.0 from 10.2.1
This works because 10.2.0 is known to Google repository ver 44.
I hope this answer will help many in future.
There are two modules you need to add firebase to:
The android module: You should use the "Add Firebase" checkbox that appears in project structure that will add 2.3.1 to the android app.
The backend module requires 2.4 to run in app engine and those steps require you to add the dependency manually.
In that case, be sure you are adding the jvm client -- not the "android" client for app engine.
compile 'com.firebase:firebase-client-android:2.4.0'
It happens because this version
compile 'com.firebase:firebase-client-android:2.3'
doesn't exist.
You can use one of these:
compile 'com.firebase:firebase-client-android:2.4.0'
compile 'com.firebase:firebase-client-android:2.3.1'
compile 'com.firebase:firebase-client-android:2.3.0'
Pay attention.
compile 'com.firebase:firebase-client-android:2.3.0'
is different from
compile 'com.firebase:firebase-client-android:2.3'
You can find the full list in maven:
using
compile 'com.firebase:firebase-client-android:+'
worked for me.
I had the exact same problem today, but with version 2.4.1. I could however not open the link l jcenter.bintray.com/com/firebase/firebase-client-android/2.4.1/ as mentioned by Mattia Maestrini.
Solution for me: Deactivate my VPN, and then it worked.
it looks like it was a dex limit error. Adding the Firebase SDK must have put me over the limit, to fix this i had to add multiDexEnabled true in the defaultConfig section of my app:build.gradle file as well as compile 'com.android.support:multidex:1.0.0' in the dependencies
Here is my gradle
gradle for project
// 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.5.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
}
gradle module app
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.tranetech.openspace.firebasedemo"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.firebase:firebase-client-android:2.5.2+'
compile 'com.firebaseui:firebase-ui:0.3.1'
compile 'com.android.support:multidex:1.0.0'
}
I not sure you still working with that project or not, but I also faced the same problem with you, my solution is
In your build.gradle (outside the app folder one), add
buildscript {
repositories {
jcenter()
}
dependencies {
////
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 in your module build.gradle, add
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.+'
compile 'com.android.support:design:23.+'
compile 'com.google.firebase:firebase-core:9.2.1'
compile 'com.google.firebase:firebase-database:9.2.1'
compile 'com.firebase:firebase-client-android:2.4.0'
}
apply plugin:
'com.google.gms.google-services'// <- this code
And the last, don't forget to download google-services.json put in your app folder, the path should look like \yourapplication\app, you also can refer to this link for download google-services.json file. Download a configuration file
compile is deprecated. You should use:
implementation 'com.firebase:firebase-client-android:2.5.2'

Categories

Resources