Firebase Cloud Messaging导致java.lang.NoSuchFieldError:没有I型字段GOOGLE_PLAY_SERVICES_VERSION_CODE [英] Firebase Cloud Messaging causes java.lang.NoSuchFieldError: No field GOOGLE_PLAY_SERVICES_VERSION_CODE of type I

查看:71
本文介绍了Firebase Cloud Messaging导致java.lang.NoSuchFieldError:没有I型字段GOOGLE_PLAY_SERVICES_VERSION_CODE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在项目中启用了FCM,但出现以下错误:

I enabled FCM in my project, but get following error:

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文件中,我有:

In my gradle files, I have:

provided "com.google.firebase:firebase-core:10.2.6"

及其一个库中:

compile libraries.firebase.messaging

在我的dependencies.gradle中:

And in my 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中,我有:

And at MyLocationManager.java at that line I have:

GoogleApiClient apiClient = new GoogleApiClient.Builder(context)
        .addApi(LocationServices.API)
        .addConnectionCallbacks(this)
        .addOnConnectionFailedListener(this)
        .build();

那这里出什么问题了?

推荐答案

替换编译library.firebase.messaging
通过编译'com.google.firebase:firebase-messaging:11.2.0'
并确保为每个Google服务使用相同的版本,即 11.2.0 .

这篇关于Firebase Cloud Messaging导致java.lang.NoSuchFieldError:没有I型字段GOOGLE_PLAY_SERVICES_VERSION_CODE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆