我已将Firebase Analytics添加到我的Android应用中。我按照these步骤进行了操作。已经搜索了原因,但到目前为止我发现的是我的firebase库不是同一个版本,情况并非如此:
来自build.gradle
dependencies {
compile 'com.google.firebase:firebase-core:9.2.0'
compile 'com.google.firebase:firebase-database:9.2.0'
compile 'com.google.firebase:firebase-auth:9.2.0'
compile 'com.google.firebase:firebase-analytics:9.2.0'
compile 'com.firebaseui:firebase-ui:0.4.4'
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.1'
compile 'com.android.support:design:25.1.1'
testCompile 'junit:junit:4.12'
}
启动应用程序时遇到的异常:(在此处用[project]替换了projectname)
E/AndroidRuntime: FATAL EXCEPTION: main
Process: [project], PID: 2764
java.lang.NoSuchMethodError: No static method zzaa(Ljava/lang/Object;)Ljava/lang/Object; in class Lcom/google/android/gms/common/internal/zzab; or its super classes (declaration of 'com.google.android.gms.common.internal.zzab' appears in /data/data/[project]/files/instant-run/dex/slice-com.google.android.gms-play-services-basement-9.4.0_6f4892c05c33d659d842b5c84c264bd97b467134-classes.dex)
at com.google.android.gms.measurement.internal.zzx.zzdo(Unknown Source)
at com.google.firebase.analytics.FirebaseAnalytics.getInstance(Unknown Source)
at [project].MainActivity.onCreate(MainActivity.java:65)
at android.app.Activity.performCreate(Activity.java:6662)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
答案 0 :(得分:1)
一个问题可能是您正在使用compile 'com.firebaseui:firebase-ui:0.4.4'
但使用版本9.2.0的firebase。
根据firebase-ui页面link和firebase 9.2.0,你应该使用版本0.4.2的firebase ui。
答案 1 :(得分:0)
您对Gradle有更多依赖吗?
您似乎正在使用导致错误的com.google.android.gms-play-services-basement-9.4.0
...
将库对齐到相同版本9.2.0或9.4.0(或者可能升级到最新版本)