更新到Android构建工具之后的IncompatibleClassChangeError 25.1.6 GCM / FCM [英] IncompatibleClassChangeError after updating to Android Build Tools 25.1.6 GCM / FCM

查看:165
本文介绍了更新到Android构建工具之后的IncompatibleClassChangeError 25.1.6 GCM / FCM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于我更新了Android SDK Tools 25.1.6和Android Support Repository 32.0.0(今天早上),我得到了以下错误,我没有更改我的代码中的任何内容,并且它仍然在我的同事计算机上工作Android SDK工具25.1.1 + Android支持库30.0.0)。

  java.lang.IncompatibleClassChangeError:方法
'java.io.File android.support.v4.content。 ContextCompat.getNoBackupFilesDir(android.content.Context)'
预计是虚拟类型,但是被发现是类型直接
(声明'java.lang.reflect.ArtMethod'出现在/ system / framework / core-libart.jar)

在com.google.android.gms.iid.zzd.zzeb(未知源代码)
在com.google.android.gms.iid .zzd。< init>(Unknown Source)
at com.google.android.gms.iid.zzd。< init>(Unknown Source)
at com.google.android.gms.iid .InstanceID.zza(Unknown Source)
at com.google.android.gms.iid.InstanceID.getInstance(Unknown Source)
at com.xxxxxxx.utils.RegistrationIntentService.onHandleIntent(RegistrationIntentService.java:55 )
at android.app.IntentService $ ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMess年龄(Handler.java:102)
在android.os.Looper.loop(Looper.java:145)
在android.os.HandlerThread.run(HandlerThread.java:61)

这是一段崩溃的代码:

  InstanceID instanceID = InstanceID.getInstance(this); //<  -  crash here 
String instanceIDToken = instanceID.getToken(getString(R.string.google_app_id),
GoogleCloudMessaging.INSTANCE_ID_SCOPE,null);

这是当我尝试从Google Cloud Messaging获取令牌时。



我使用spl-play服务在Gradle中导入GCM:

  compile'c​​om.google .android.gms:play-services-analytics:9.0.0'
compile'c​​om.google.android.gms:play-services-maps:9.0.0'
compile'c​​om.google.android .gms:play-services-location:9.0.0'
compile'c​​om.google.android.gms:play-services-gcm:9.0.0'
compile'c​​om.google.android.gms :play-services-base:9.0.0'

编辑
禁用GCM修复了这个问题,所以我的猜测是我应该迁移到Firebase Cloud Message



EDIT2
我的设备收到Google Play Services 9.0(昨天是8.4.x)。现在它不再崩溃,但抱怨模块描述符

 加载模块描述符类失败:找不到类 com.google.android.gms.dynamite.descriptors.com.google.firebase.auth.ModuleDescriptor
Firebase API初始化失败。

有没有人有类似的错误,以及如何解决它?



固定
特别感谢@stegranet。
./ gradlew -q app:dependencies --configuration compile 可帮助您确定哪些依赖项包含SDK 24.x

主要问题是某些库使用 + 符号而不是版本导入最新的支持库。这导致了问题,通过包括最新的可用版本。



因此,避免 + 登录依赖关系; p>

解决方案

使用gradle依赖关系树为我解决这个错误。

只需运行 gradle -q app:dependencies --configuration compile
并检查输出是否有这样的条目:

  + --- com.mcxiaoke.viewpagerindicator:library:2.4.1 
| \ --- com.android.support:support-v4:+ - > 24.0.0-beta1(*)

As Diego Giorgini 说这个版本过高(> = 24)。
因此,更新 build.gradle 中的依赖关系,比如

  compile('com.mcxiaoke.viewpagerindicator:library:2.4.1'){
exclude module:'support-v4';
}
compile'c​​om.android.support:support-v4:23.4.0'


Since I updated to Android SDK Tools 25.1.6 and Android Support Repository 32.0.0 (this morning), I got the following error, I didn't change anything in my code and it is still working on my colleague computer (Android SDK Tools 25.1.1 + Android Support Repository 30.0.0).

java.lang.IncompatibleClassChangeError: The method 
     'java.io.File android.support.v4.content.ContextCompat.getNoBackupFilesDir(android.content.Context)' 
     was expected to be of type virtual but instead was found to be of type direct 
     (declaration of 'java.lang.reflect.ArtMethod' appears in /system/framework/core-libart.jar)

     at com.google.android.gms.iid.zzd.zzeb(Unknown Source)
     at com.google.android.gms.iid.zzd.<init>(Unknown Source)
     at com.google.android.gms.iid.zzd.<init>(Unknown Source)
     at com.google.android.gms.iid.InstanceID.zza(Unknown Source)
     at com.google.android.gms.iid.InstanceID.getInstance(Unknown Source)
     at com.xxxxxxx.utils.RegistrationIntentService.onHandleIntent(RegistrationIntentService.java:55)
     at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
     at android.os.Handler.dispatchMessage(Handler.java:102)
     at android.os.Looper.loop(Looper.java:145)
     at android.os.HandlerThread.run(HandlerThread.java:61)

Here is a the piece of code that crash:

InstanceID instanceID = InstanceID.getInstance(this); // <-- crash here
String instanceIDToken = instanceID.getToken(getString(R.string.google_app_id),
GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);

It is when I try to get a token from Google Cloud Messaging.

I'm importing GCM in Gradle with splited play-services :

 compile 'com.google.android.gms:play-services-analytics:9.0.0' 
 compile 'com.google.android.gms:play-services-maps:9.0.0'
 compile 'com.google.android.gms:play-services-location:9.0.0' 
 compile 'com.google.android.gms:play-services-gcm:9.0.0' 
 compile 'com.google.android.gms:play-services-base:9.0.0'

EDIT disabling GCM fixed the problem, so my guess is I should migrate to Firebase Cloud Message

EDIT2 My device receive Google Play Services 9.0 (yesterday was 8.4.x). Now it doesn't crash anymore, but complain about module descriptor

 Failed to load module descriptor class: Didn't find class "com.google.android.gms.dynamite.descriptors.com.google.firebase.auth.ModuleDescriptor"
 Firebase API initialization failure.

Does anyone has a similar error, and how to fix it ?

FIXED special thanks to @stegranet. ./gradlew -q app:dependencies --configuration compile helps you to identify what dependencies include SDK 24.x

Main issue is some library import the latest support library using + sign instead of a version. This cause the issue, by including the latest available version.

So avoid + sign in dependencies ;)

解决方案

I used the gradle dependency tree to solve this error for me.

Just run gradle -q app:dependencies --configuration compile and check the output for entries like this:

+--- com.mcxiaoke.viewpagerindicator:library:2.4.1
|    \--- com.android.support:support-v4:+ -> 24.0.0-beta1 (*)

As Diego Giorgini said this version is too high (>=24). So update the dependencies in build.gradle like

compile('com.mcxiaoke.viewpagerindicator:library:2.4.1') {
    exclude module: 'support-v4';
}
compile 'com.android.support:support-v4:23.4.0'

这篇关于更新到Android构建工具之后的IncompatibleClassChangeError 25.1.6 GCM / FCM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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