С тех пор как я обновился до Android SDK Tools 25.1.6 и Android Support Repository 32.0.0 (сегодня утром), я получил следующую ошибку, я ничего не менял в своем коде, и он все еще работает на моем компьютере коллеги ( 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)
Вот фрагмент кода, который сбой:
InstanceID instanceID = InstanceID.getInstance(this); // <-- crash here
String instanceIDToken = instanceID.getToken(getString(R.string.google_app_id),
GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
Это когда я пытаюсь получить токен из облачных сообщений Google.
Я импортирую GCM в Gradle с разделенными игровыми сервисами:
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'
ИЗМЕНИТЬ отключив GCM, исправлена проблема, поэтому я предполагаю, что я должен перейти на Firebase Cloud Message
EDIT2 На моем устройстве Google Play Services 9.0 (вчера было 8.4.x). Теперь он больше не падает, но жалуется на дескриптор модуля
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.
Есть ли у кого-то подобная ошибка и как ее исправить?
Fixed
Особая благодарность @stegranet.
./gradlew -q app:dependencies --configuration compile
помогает определить, какие зависимости включают SDK 24.x
Основная проблема - некоторая библиотека импортирует последнюю библиотеку поддержки, используя знак +
вместо версии. Это вызывает проблему, включая последнюю доступную версию.
Поэтому избегайте зависимостей sign +
;)