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