我在项目中启用了FCM,但收到以下错误:
E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.app, PID: 28654
java.lang.NoSuchFieldError: No field GOOGLE_PLAY_SERVICES_VERSION_CODE of type I in class Lcom/google/android/gms/common/zzc; or its superclasses (declaration of 'com.google.android.gms.common.zzc' appears in /data/app/com.example.app-2/base.apk:classes40.dex)
at com.google.android.gms.common.GoogleApiAvailability.<clinit>(Unknown Source)
at com.google.android.gms.common.GoogleApiAvailability.getInstance(Unknown Source)
at com.google.android.gms.common.api.GoogleApiClient$Builder.<init>(Unknown Source)
at com.example.app.location.MyLocationManager.<init>(MyLocationManager.java:39)
在我的gradle文件中,我有:
provided "com.google.firebase:firebase-core:10.2.6"
并在其中一个库中:
compile libraries.firebase.messaging
在我的dependencies.gradle中:
libraries = [
firebase : [
crash : "com.google.firebase:firebase-crash:$versions.google.play.services",
messaging: "com.google.firebase:firebase-messaging:$versions.google.play.services"
],
]
在该行的MyLocationManager.java,我有:
GoogleApiClient apiClient = new GoogleApiClient.Builder(context)
.addApi(LocationServices.API)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
那么这个问题是什么?
答案 0 :(得分:0)
替换compile libraries.firebase.messaging
按compile 'com.google.firebase:firebase-messaging:11.2.0'
选择,并确保为每个Google服务使用相同版本,即11.2.0
。