title: Crash combining Firebase and Realm - Failed resolution of: Lio/reactivex/Observable;
body: <p>I am trying to download objects from Firebase and store them in Realm. I am receiving a crash when combining these two excellent libraries.</p>
  
  <p>I've created a very simple demo app which illustrates my problem. It seems Firebase gets upset when creating an object that extends RealmObject.</p>
  
  <p>I can make this work by removing the RealmObject extension but then I have to maintain two identical objects. Over time this becomes complicated and frustrating which is far from ideal.</p>
  
  <p><strong>Firebase:</strong></p>
  
  <pre><code>    FirebaseDatabase database = FirebaseDatabase.getInstance();
      DatabaseReference myRef = database.getReference("players");
  
      myRef.addValueEventListener(new ValueEventListener() {
          @Override
          public void onDataChange(DataSnapshot dataSnapshot) {
              Log.d(TAG, "onDataChange: " + dataSnapshot.getChildrenCount());
  
              for (DataSnapshot snapshot : dataSnapshot.getChildren()) {
                  //***CRASH here*****
                  Player player = snapshot.getValue(Player.class);
                  Log.d(TAG, "onDataChange: " + player.getFirstname());
              }
          }
  
          @Override
          public void onCancelled(DatabaseError databaseError) {
              Log.e(TAG, "onCancelled: ", databaseError.toException());
          }
      });
  </code></pre>
  
  <p><strong>Player:</strong></p>
  
  <pre><code>public class Player extends RealmObject{
  private int age;
  private String firstname;
  
  public Player() {
  }
  
  //getters and setters
  }
  </code></pre>
  
  <p><strong>Gradle</strong>:</p>
  
  <pre><code>compile 'com.google.firebase:firebase-database:11.8.0'
  compile 'io.reactivex:rxandroid:1.2.1'
  compile 'io.reactivex:rxjava:1.1.6'
  </code></pre>
  
  <p><strong>Realm</strong>:</p>
  
  <pre><code>classpath 'io.realm:realm-gradle-plugin:4.3.1'
  </code></pre>
  
  <p><strong>Error</strong>:</p>
  
  <pre><code>FATAL EXCEPTION: main
  Process: com.test.testrealm, PID: 7616
  java.lang.NoClassDefFoundError: Failed resolution of: Lio/reactivex/Observable;
  
    at java.lang.reflect.Executable.getMethodReturnTypeInternal(Native Method)
    at java.lang.reflect.Method.getReturnType(Method.java:141)
    at java.lang.Class.getDeclaredMethods(Class.java:1880)
    at com.google.android.gms.internal.zzelx.&lt;init&gt;(Unknown Source:310)
    at com.google.android.gms.internal.zzelw.zzf(Unknown Source:12)
    at com.google.android.gms.internal.zzelw.zzb(Unknown Source:182)
    at com.google.android.gms.internal.zzelw.zza(Unknown Source:0)
    at com.google.firebase.database.DataSnapshot.getValue(Unknown Source:10)
    at com.test.testrealm.MainActivity$2.onDataChange(MainActivity.java:41)
    at com.google.android.gms.internal.zzegf.zza(Unknown Source:13)
    at com.google.android.gms.internal.zzeia.zzbyc(Unknown Source:2)
    at com.google.android.gms.internal.zzeig.run(Unknown Source:71)
    at android.os.Handler.handleCallback(Handler.java:790)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6494)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
  Caused by: java.lang.ClassNotFoundException: Didn't find class "io.reactivex.Observable" on path: DexPathList[[zip file "/data/app/com.test.testrealm-Mj0Zh1FN_CGS6fFGuEYfWQ==/base.apk", zip file "/data/app/com.test.testrealm-Mj0Zh1FN_CGS6fFGuEYfWQ==/split_lib_dependencies_apk.apk", zip file "/data/app/com.test.testrealm-Mj0Zh1FN_CGS6fFGuEYfWQ==/split_lib_resources_apk.apk", zip file "/data/app/com.test.testrealm-Mj0Zh1FN_CGS6fFGuEYfWQ==/split_lib_slice_0_apk.apk", zip file "/data/app/com.test.testrealm-Mj0Zh1FN_CGS6fFGuEYfWQ==/split_lib_slice_1_apk.apk", zip file "/data/app/com.test.testrealm-Mj0Zh1FN_CGS6fFGuEYfWQ==/split_lib_slice_2_apk.apk", zip file "/data/app/com.test.testrealm-Mj0Zh1FN_CGS6fFGuEYfWQ==/split_lib_slice_3_apk.apk", zip file "/data/app/com.test.testrealm-Mj0Zh1FN_CGS6fFGuEYfWQ==/split_lib_slice_4_apk.apk", zip file "/data/app/com.test.testrealm-Mj0Zh1FN_CGS6fFGuEYfWQ==/split_lib_slice_5_apk.apk", zip file "/data/app/com.test.testrealm-Mj0Zh1FN_CGS6fFGuEYfWQ==/split_lib_slice_6_apk.apk", zip file "/data/app/com.test.testrealm-Mj0Zh1FN_CGS6fFGuEYfWQ==/split_lib_slice_7_apk.apk", zip file "/data/app/com.test.testrealm-Mj0Zh1FN_CGS6fFGuEYfWQ==/split_lib_slice_8_apk.apk", zip file "/data/app/com.test.testrealm-Mj0Zh1FN_CGS6fFGuEYfWQ==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.test.testrealm-Mj0Zh1FV_CGS7fFGuEYfWQ==/lib/arm64, /data/app/com.test.testrealm-Mj0Zh1FV_CGS7fFGuEYfWQ==/base.apk!/lib/arm64-v8a, /data/app/com.test.testrealm-Mj0Zh1FN_CGS6fFGuEYfWQ==/split_lib_dependencies_apk.apk!/lib/arm64-v8a, /data/app/com.test.testrealm-Mj0Zh1FN_CGS6fFGuEYfWQ==/split_lib_resources_apk.apk!/lib/arm64-v8a, /data/app/com.test.testrealm-Mj0Zh1FN_CGS6fFGuEYfWQ==/split_lib_slice_0_apk.apk!/lib/arm64-v8a, /data/app/com.test.testrealm-Mj0Zh1FN_CGS6fFGuEYfWQ==/split_lib_slice_1_apk.apk!/lib/arm64-v8a, /data/app/com.test.testrealm-Mj0Zh1FN_CGS6fFGuEYfWQ==/split_lib_slice_2_apk.apk!/lib/arm64-v8a, /data/app/com.test.testrealm-Mj0Zh1FN_CGS6fFGuEYfWQ==/split_lib_slice_3_apk.apk!/lib/arm64-v8a, /data/app/com.test.testrealm-Mj0Zh1FN_CGS6fFGuEYfWQ==/split_lib_slice_4_apk.apk!/lib/arm64-v8a, /data/app/com.test.testrealm-Mj0Zh1FN_CGS6fFGuEYfWQ==/split_lib_slice_5_apk.apk!/lib/arm64-v8a, /data/app/com.test.testrealm-Mj0Zh1FN_CGS6fFGuEYfWQ==/split_lib_slice_6_apk.apk!/lib/arm64-v8a, /data/app/com.test.testrealm-Mj0Zh1FN_CGS6fFGuEYfWQ==/split_lib_slice_7_apk.apk!/lib/arm64-v8a, /data/app/com.test.testrealm-Mj0Zh1FN_CGS6fFGuEYfWQ==/split_lib_slice_8_apk.apk!/lib/arm64-v8a, /data/app/com.test.testrealm-Mj0Zh1FN_CGS6fFGuEYfWQ==/split_lib_slice_9_apk.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
  01-10 10:24:06.881 7616-7616/com.test.testrealm E/AndroidRuntime:     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
      ... 19 more
  Suppressed: java.io.IOException: No original dex files found for dex location /data/app/com.test.testrealm-Mj0Zh1FV_CGS7fFGuEYfWQ==/split_lib_resources_apk.apk
    at dalvik.system.DexFile.openDexFileNative(Native Method)
    at dalvik.system.DexFile.openDexFile(DexFile.java:353)
    at dalvik.system.DexFile.&lt;init&gt;(DexFile.java:100)
    at dalvik.system.DexFile.&lt;init&gt;(DexFile.java:74)
    at dalvik.system.DexPathList.loadDexFile(DexPathList.java:374)
    at dalvik.system.DexPathList.makeDexElements(DexPathList.java:337)
    at dalvik.system.DexPathList.&lt;init&gt;(DexPathList.java:157)
    at dalvik.system.BaseDexClassLoader.&lt;init&gt;(BaseDexClassLoader.java:65)
    at dalvik.system.PathClassLoader.&lt;init&gt;(PathClassLoader.java:64)
    at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:73)
    at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:88)
    at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:69)
    at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:35)
    at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:693)
    at android.app.LoadedApk.getClassLoader(LoadedApk.java:727)
    at android.app.LoadedApk.getResources(LoadedApk.java:954)
    at android.app.ContextImpl.createAppContext(ContextImpl.java:2270)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5639)
    at android.app.ActivityThread.-wrap1(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656)
    at android.os.Handler.dispatchMessage(Handler.java:106)
  </code></pre>