0

I tried use the google notifications in android app using Android Studio, well i have this class to Registration Service

public class GCMRegistrationIntentService extends IntentService
{

public static final String REGISTRATION_SUCCESS = "RegistrationSuccess";
public static final String REGISTRATION_ERROR = "RegistrationError";

public GCMRegistrationIntentService() {
    super("");
}


@Override
protected void onHandleIntent(Intent intent) {
    registerGCM();
}

private void registerGCM() {
    Intent registrationComplete = null;
    String token = null;
    try {
        InstanceID instanceID = InstanceID.getInstance(getApplicationContext());
        token = instanceID.getToken(getString(R.string.gcm_defaultSenderId), GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
        Log.w("GCMRegIntentService", "token:" + token);
        //notify to UI that registration complete success
        registrationComplete = new Intent(REGISTRATION_SUCCESS);
        registrationComplete.putExtra("token", token);
    } catch (Exception e) {
        Log.w("GCMRegIntentService", "Registration error");
        registrationComplete = new Intent(REGISTRATION_ERROR);
    }
    //Send broadcast
    LocalBroadcastManager.getInstance(this).sendBroadcast(registrationComplete);
}

}

but when i try to call the method registerGCM() It shows me this error

06-29 18:00:39.611 5494-5539/com.cisaApp.adrian.cisaappacueductos E/AndroidRuntime: FATAL EXCEPTION: IntentService[]
                                                                                Process: com.cisaApp.adrian.cisaappacueductos, PID: 5494
                                                                                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.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.cisaApp.adrian.cisaappacueductos.GCMRegistrationIntentService.registerGCM(GCMRegistrationIntentService.java:34)
                                                                                    at com.cisaApp.adrian.cisaappacueductos.GCMRegistrationIntentService.onHandleIntent(GCMRegistrationIntentService.java:27)
                                                                                    at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
                                                                                    at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                    at android.os.Looper.loop(Looper.java:135)
                                                                                    at android.os.HandlerThread.run(HandlerThread.java:61)

specifically the line

InstanceID instanceID = InstanceID.getInstance(getApplicationContext());

1 Answers1

0

For your error IncompatibleClassChangeError, according to this thread, it means that you have made some incompatible binary changes to the library without recompiling the client code. For more information about this issue, just read the above link.

So for the solution to your problem, you can follow the solution in this related SO question. Try to used the gradle dependency tree to solve this error.

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 (*)

Also update your dependencies to the latest version to solve this.

Community
  • 1
  • 1
KENdi
  • 7,576
  • 2
  • 16
  • 31