title: Error while getting GCM token in client side
body: <p>package nath.prem.com.premgcmproject;</p>
  
  <p>import android.content.Intent;</p>
  
  <p>import com.google.android.gms.iid.InstanceIDListenerService;</p>
  
  <p>/** * Created by prem on 22/7/16. */ public class GCMTokenRefreshListenerService extends InstanceIDListenerService {</p>
  
  <p>//If the token is changed registering the device again @Override public void onTokenRefresh() { Intent intent = new Intent(this, GCMRegistrationIntentService.class); startService(intent); } }</p>
  
  <p><strong><em>Error while getting GCM token in client side</em></strong> </p>
  
  <p>FATAL EXCEPTION: IntentService[]</p>
  
  <p>java.lang.IncompatibleClassChangeError: android.support.v4.content.ContextCompat at com.google.android.gms.iid.zzd.zzdL(Unknown Source) </p>
  
  <p>at</p>
  
  <p>com.google.android.gms.iid.zzd.(Unknown Source) at com.google.android.gms.iid.zzd.(Unknown Source) at com.google.android.gms.iid.InstanceID.zza(Unknown Source) at com.google.android.gms.iid.InstanceID.getInstance(Unknown Source)</p>
  
  <p><strong>this is the error I am getting while getting gcm token</strong></p>
  
  <p>public class GCMRegistrationIntentService extends IntentService { //Constants for success and errors public static final String REGISTRATION_SUCCESS = "RegistrationSuccess"; public static final String REGISTRATION_ERROR = "RegistrationError"; //Class constructor public GCMRegistrationIntentService() { super(""); } @Override protected void onHandleIntent(Intent intent) { //Registering gcm to the device registerGCM(); } private void registerGCM() { //Registration complete intent initially null Intent registrationComplete = null; //Register token is also null //we will get the token on successfull registration String token = null; SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); try { //Creating an instanceid InstanceID instanceID = InstanceID.getInstance(this); // // //Getting the token from the instance id token = instanceID.getToken(getString(R.string.gcm_defaultSenderId), GoogleCloudMessaging.INSTANCE_ID_SCOPE, null); //Displaying the token in the log so that we can copy it to send push notification //You can also extend the app by storing the token in to your server Log.w("GCMRegIntentService", "token:" + token); //on registration complete creating intent with success registrationComplete = new Intent(REGISTRATION_SUCCESS); //Putting the token to the intent // registrationComplete.putExtra("token", token); } catch (Exception e) { //If any error occurred Log.w("GCMRegIntentService", "Registration error"); registrationComplete = new Intent(REGISTRATION_ERROR); } //Sending the broadcast that registration is completed LocalBroadcastManager.getInstance(this).sendBroadcast(registrationComplete); } }</p>
  
  <p><strong>this is the java code of that class</strong></p>
  
  <p> </p>
  
  <p>  </p>
  
  <p>  </p>
  
  <p> </p>
  
  <p>   </p>
  
  <p>   </p>
  
  <p>   </p>
  
  <p>  </p>
  
  <p>    </p>
  
  <p>    </p>
  
  <p> </p>
  
  <p></p>
  
  <p><strong>this is my menifest file in the project......But I cannot see any of the logs in RegistrationIntentService:</strong></p>