Anshul Patro Anshul Patro - 5 months ago 106
Android Question

Error on adding firebase dependency in android

I am trying to add firebase dependency in my project. I already gsm play services dependencies added, as soon as I insert firebase dependency, gsm dependency shows error.

buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
jcenter()
}

dependencies {
classpath 'io.fabric.tools:gradle:1.21.6'
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.google.gms:google-services:2.0.0-alpha6'

}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
maven { url 'https://maven.fabric.io/public' }
}

repositories {
mavenCentral()
}


android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
applicationId "abc.abc.abc.xyz"
minSdkVersion 17
targetSdkVersion 23
versionCode 60
versionName "42.0.0.19"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
transitive = true;
}

compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:support-v4:23.1.1+'
compile 'com.android.support:design:23.2.1'
compile 'com.android.support:recyclerview-v7:23.2.1'
compile 'com.android.support:cardview-v7:23.3.0'
compile 'de.hdodenhof:circleimageview:1.2.1'
compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4'
compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta4'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'io.branch.sdk.android:library:1.10.8'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.github.traex.rippleeffect:library:1.3'
compile 'com.android.support:support-v4:23.2.1'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.weiwangcn.betterspinner:library-material:1.1.0'
compile 'uk.co.chrisjenx.calligraphy:calligraphy:0.6.0'
compile 'com.clevertap.android:clevertap-android-sdk:2.0.10'
compile 'com.google.android.gms:play-services-base:8.4.0'
compile 'com.google.android.gms:play-services-basement:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.android.gms:play-services-location:8.4.0'
compile 'com.ogaclejapan.smarttablayout:library:1.2.1@aar'
compile 'org.greenrobot:eventbus:3.0.0'
compile files('libs/android-viewbadger.jar')
compile 'com.parse.bolts:bolts-android:1.+'
compile 'com.parse:parse-android:1.+'
compile 'com.github.ksoichiro:android-observablescrollview:1.5.0'
compile 'me.leolin:ShortcutBadger:1.1.4@aar'
compile 'com.google.android.gms:play-services-auth:8.4.0'
compile 'com.google.firebase:firebase-messaging:9.0.2'
}


It points error in gms play services library

Answer
classpath 'com.google.gms:google-services:2.0.0-alpha6'

i beleive this line should be on your project-level build.gradle, not on the app-level one, and the version should be 3.0.0

another thing is that you can't have play-services on different versions, all should be the same.

try replacing this:

compile 'com.google.android.gms:play-services-auth:8.4.0'
compile 'com.google.firebase:firebase-messaging:9.0.2'

for this:

compile 'com.google.android.gms:play-services-auth:9.0.2'
compile 'com.google.firebase:firebase-messaging:9.0.2'

and that with all dependencies from play-services (firebase included)

also, you may encounter (as i did) with an error that 9.0.2 is not found, replace them with 9.0.0 and should work

(PS: Sorry if my english is bad ;) )