sonique sonique - 2 years ago 812
Android Question

IncompatibleClassChangeError after updating to Android Build Tools 25.1.6 GCM / FCM

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
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 Source)
at<init>(Unknown Source)
at<init>(Unknown Source)
at Source)
at Source)
at com.xxxxxxx.utils.RegistrationIntentService.onHandleIntent(
at android.os.Handler.dispatchMessage(
at android.os.Looper.loop(

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 ''
compile ''
compile ''
compile ''
compile ''

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

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 ""
Firebase API initialization failure.

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

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 ;)

Answer Source

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
|    \--- -> 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 ''
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download