我正在努力将Firebase通知添加到我的Android应用程序中。我做了所有firebase-android所需。
build.gradle(project):
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.grudle(app):
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:25.1.0'
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:25.1.0'
compile 'com.google.firebase:firebase-core:10.2.0'
compile 'com.google.firebase:firebase-messaging:10.0.1'
}
apply plugin: 'com.google.gms.google-services'
但它显示了很多遗漏 - 未知来源
02-20 18:57:56.634 925-925/com.sarazeef.teaoria E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.sarazeef.teaoria, PID: 925
java.lang.NoSuchMethodError: No static method zzaaj()Lcom/google/firebase/iid/zzg; in class Lcom/google/firebase/iid/zzg; or its super classes (declaration of 'com.google.firebase.iid.zzg' appears in /data/data/com.sarazeef.teaoria/files/instant-run/dex/slice-com.google.firebase-firebase-iid-10.2.0_d53622db8f96b7ec4a26866e04f3b40994f5004d-classes.dex)
at com.google.firebase.messaging.FirebaseMessagingService.zzF(Unknown Source)
at com.google.firebase.iid.zzb.onStartCommand(Unknown Source)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4128)
at android.app.ActivityThread.access$2400(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1924)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7325)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
我需要解决方案。
答案 0 :(得分:0)
我注意到您使用不同版本的Firebase SDK进行firebase-core和firebase-messaging - 这可能是问题所在? 此外,将依赖项版本移动到公共位置是一种很好的做法,这样您就可以为所有版本更新版本 - https://medium.com/@ivan_m/use-variables-to-manage-gradle-android-dependencies-library-version-numbers-92f0e362a2fc#.qsxuygtl7。