在android中添加firebase依赖项时出错

时间:2016-06-07 10:33:54

标签: android firebase android-gradle

我正在尝试在我的项目中添加firebase依赖项。我已经添加了gsm play服务依赖项,只要我插入firebase依赖项,gsm依赖项就会显示错误。

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'
}

它指出gms播放服务库中的错误

3 个答案:

答案 0 :(得分:3)

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

我相信这一行应该在您的项目级build.gradle上,而不是在应用程序级别上,版本应该是3.0.0

另一件事是你不能在不同的版本上提供播放服务,所有版本都应该是相同的。

尝试替换它:

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

为此:

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

以及来自play-services的所有依赖项(包括firebase)

另外,你可能会遇到(因为我做的)错误,找不到9.0.2,用9.0.0替换它们并且应该工作

(PS:对不起,如果我的英语不好;))

答案 1 :(得分:1)

使用gsm 3.0.0版将firebase消息传递降级到9.0.0对我来说也很奇怪。

答案 2 :(得分:0)

由于firebase-messaging正在替换gcm,因此您需要从build.gradle中删除此行:

compile 'com.google.android.gms:play-services-gcm:8.4.0'