我正在努力将firebase通知添加到我的Android应用程序中。我完成了所有需要的firebase-android。
build.gradle(项目):
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)
我需要解决方案。
我注意到您正在使用不同版本的firebase SDK进行firebase-core和firebase-messging-也许这是问题?此外,最好将依赖版本移至一个共同的位置,以便您可以一次更新版本-https://medium.com/@ivan_m/use-variables-to-manage-manage-manage-gradle-android-dependencies-library-version-numbers-92f0e362a2a2fc#.qsxuygtl7。