My application used GCM push notification service. Everything worked fine until I recently updated the SDK version to 25

This is what app gradle looked like:

apply plugin: 'com.android.application' apply plugin: 'com.google.gms.google-services' android { compileSdkVersion 23 buildToolsVersion "23.0.0" defaultConfig { applicationId "com.frienddime.frienddime" minSdkVersion 10 targetSdkVersion 23 versionCode 107 versionName "1.2.3" } ... } dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.3.0' compile 'com.android.support:cardview-v7:23.3.0' compile 'com.android.support:recyclerview-v7:23.3.0' compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5' compile 'com.squareup.okhttp3:okhttp:3.2.0' compile 'com.vk:androidsdk:+' compile 'com.google.android.gms:play-services:8.3.0' } 

And after the update, this error began to take off. The line of code pointed to by the error is exactly where the GCM registration service is trying to get the GCM token.

 FATAL EXCEPTION: IntentService[] java.lang.IllegalAccessError: tried to access method android.support.v4.content.ContextCompat.<init>:(Ljava/lang/String;)V from class com.google.android.gms.iid.zzd at com.google.android.gms.iid.zzd.zzdL(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.frienddime.frienddime.GCMRegistrationIntentService.registerGCM(GCMRegistrationIntentService.java:31) at com.frienddime.frienddime.GCMRegistrationIntentService.onHandleIntent(GCMRegistrationIntentService.java:24) at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.os.HandlerThread.run(HandlerThread.java:60) 

I tried to change compileSdkVersion 25, buildToolsVersion "25.0.0", targetSdkVersion 25. Then I found in Google that this is the case in compile 'com.google.android.gms: play-services: 8.3.0', that the pier must be changed to the last version of. However, I tried to change to the one that was recommended 9.8.0, but as a result, the graidle gave an error that this version is incompatible with other libraries. I tried the latest version 10.0.1, but the same. I changed the version of com.android.support to 25.1.0 and this also did not help.

Why does this error occur and how to solve it?

  • Try again to upgrade all versions of compileSdkVersion, buildToolsVersion and targetSdkVersion, and also move apply plugin: 'com.google.gms.google-services' to the end of the file - Yuriy SPb
  • @YuriSPb did, but did not help, when synchronizing writes: Error: Execution failed for task ': app: processDebugGoogleServices'. > If you’re checking out the google-services plugin or updating the version of com.google.android.gms to 8.3.0. - cheerful_weasel
  • @YuriSPb I inserted the classpath 'com.google.gms: google-services: 3.0.0' into the gradle Project file; now the graiddle is synchronized without errors, but when you start the project, it now gives this Error: The number of method references in a .dex file cannot exceed 64K. Learn how to resolve this issue at developer.android.com/tools/building/multidex.html Error: Execution failed for task ': app: transformClassesWithDexForDebug'. > com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationExceptio - cheerful_weasel
  • You have exceeded the number of methods. The solution is here: www.stackoverflow.com/a/482874/17609 And also for the link you provided, which is in your own log of your own error - Yuriy б
  • Thanks, I will try. - cheerful_weasel

0