title: Need help dealing with a Fatal Exception caused by java.lang.IncompatibleClassChangeError
body: <p>So, I ran into this error just yesterday in Android Studio that I've never seen before, caused by a piece of code that hasn't been touched over the past 3 months. This came from the code being used to register for push notifications and was working fine earlier this week, but now it results in this error:</p>
  
  <pre><code>05-20 10:37:02.064 22471-22681/com.appname E/AndroidRuntime: FATAL EXCEPTION: IntentService[RegIntentService]
                                                                 Process: com.appname, PID: 22471
                                                                 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.&lt;init&gt;(Unknown Source)
                                                                     at com.google.android.gms.iid.zzd.&lt;init&gt;(Unknown Source)
                                                                     at com.google.android.gms.iid.InstanceID.zza(Unknown Source)
                                                                     at com.google.android.gms.iid.InstanceID.getInstance(Unknown Source)
                                                                     at com.appname.services.RegistrationIntentService.onHandleIntent(RegistrationIntentService.java:32)
                                                                     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)
  </code></pre>
  
  <p>Here is my RegistrationIntentService class:</p>
  
  <pre><code>package com.appname.services;
  
  import android.app.IntentService;
  import android.content.Context;
  import android.content.Intent;
  import com.google.android.gms.gcm.GoogleCloudMessaging;
  import com.google.android.gms.iid.InstanceID;
  import com.appname.MainSharedPreferences;
  import com.appname.R;
  import java.io.IOException;
  
  public class RegistrationIntentService extends IntentService {
  
      private static final String TAG = "RegIntentService";
  
      public RegistrationIntentService() {
          super(TAG);
      }
      public static void startService(final Context context) {
          final Intent intent = new Intent(context, RegistrationIntentService.class);
          context.startService(intent); //HERE is the line that is causing the crash
      }
  
      @Override
      public void onHandleIntent(Intent intent) {
          InstanceID instanceID = InstanceID.getInstance(this);
          try {
              String token = instanceID.getToken(getString(R.string.gcm_defaultSenderId) , GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
              MainSharedPreferences.saveGCMInstanceToken(token, getApplicationContext());
          } catch (IOException e) {
              e.printStackTrace();
          }
      }
  </code></pre>
  
  <p>This is the line of code that is calling the above class from my MainActivity class:</p>
  
  <pre><code>RegistrationIntentService.startService(getApplicationContext());
  </code></pre>
  
  <p>Some info on my MainActivity if it helps...</p>
  
  <pre><code>public class MainActivity extends SocialActivity implements SeekBar.OnSeekBarChangeListener
  
  public abstract class SocialActivity extends AppCompatActivity implements GraphRequest.GraphJSONObjectCallback
  </code></pre>
  
  <p>I've tried jumping back to several older commits, but got the same error. This led me to believe that maybe there was problem with my Android Studio or java version. I updated my java version and reinstalled Android Studio, still the same error. Also tried on a separate computer with older versions, still the same error.</p>
  
  <p>I even tried migrating from GCM to Firebase according to <a href="https://developers.google.com/cloud-messaging/android/android-migrate-fcm">this guide</a> and ended up getting the same error again.</p>
  
  <p>I can comment out the line that crashes the app and it will run fine, but then I no longer receive notifications.</p>
  
  <p>Any help or advice on this matter would be much appreciated!</p>
  
  <p><strong>EDIT:</strong> Here are my relevant compile/classpath statements as well...</p>
  
  <p>In the appname build.gradle:</p>
  
  <pre><code>buildscript {
      repositories {
          jcenter()
      }
      repositories { mavenCentral() }
      dependencies {
          classpath 'com.android.tools.build:gradle:2.1.0'
          classpath 'com.google.gms:google-services:3.0.0'
  
          // NOTE: Do not place your application dependencies here; they belong
          // in the individual module build.gradle files
      }
  }
  </code></pre>
  
  <p>In the app build.gradle:</p>
  
  <pre><code>apply plugin: 'com.android.application'
  apply plugin: 'io.fabric'
  
  repositories {
      //...
  }
  
  allprojects {
      //...
  }
  
  android {
     //...
  }
  
  dependencies {
      compile fileTree(dir: 'libs', include: ['*.jar'])
      testCompile 'junit:junit:4.12'
      compile 'com.android.support:appcompat-v7:23.4.0'
      compile 'com.google.code.gson:gson:2.5'
      compile 'com.android.support:design:23.4.0'
      compile 'com.android.support:recyclerview-v7:+'
      compile "com.google.firebase:firebase-messaging:9.0.0"
      //...
  }
  
  apply plugin: 'com.google.gms.google-services'
  </code></pre>