我正在设置一个Android服务器项目,用于从Firebase网站使用this documentation推送通知。首先,我在Firebase控制台上设置了项目并添加了JSON文件& Google服务插件。
但在添加后同步项目时
compile 'com.google.firebase:firebase-server-sdk:3.0.1'
,有错误:
Version: 3.0.1 is lower than the minimum version (9.0.0) required for google-services plugin.
我的应用build.gradle是 -
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "ton.com.serverandroid"
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
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:24.2.1'
compile 'com.google.firebase:firebase-server-sdk:3.0.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
我的项目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.2.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()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
我曾尝试使用google-services版本2.1.0,但它无法正常使用错误:
Conflict with dependency 'com.google.code.findbugs:jsr305'. Resolved versions for app (1.3.9) and test app (2.0.1) differ.
但在这种情况下我不能再往前走了。
答案 0 :(得分:0)
我今天回答了一个类似的问题,你可以在这里看到正确的依赖enter link description here,这对于在android客户端中导入其他依赖是最重要的。然后对于服务器sdk,您需要在 app.gradle 中添加这个:
compile 'com.google.firebase:firebase-server-sdk:[3.0.0,)'
要使用FirebaseCloudMessaging,您需要 app.gradle 中的其他人:
compile 'com.google.firebase:firebase-messaging:9.0.0'
告诉我们您现在是否愿意编译,问候!