Realm 5.8.0 causes dex error under Android

Viewed 1559

I have an Android app that is building and running fine under Realm 5.7.0. I just upgraded my gradle to 5.8.0, and the initial sync went fine, but then when I tried to execute the app to my emulator, I got this error:

com.android.builder.dexing.DexArchiveBuilderException: Failed to process C:\Users\frysingg\.gradle\caches\transforms-1\files-1.1\jetified-realm-android-library-5.8.0.aar\c1094bb66029494e6cdb95ba0999c5a7\jars\classes.jar 
com.android.builder.dexing.DexArchiveBuilderException: Error while dexing.  
com.android.tools.r8.CompilationFailedException: Compilation failed to complete 
com.android.tools.r8.utils.AbortException: Error: Invoke-customs are only supported starting with Android O (--min-api 26)  

Doing a clean, rebuild, clearing the Android Studio cache and restarting don't help. Moving back to 5.7.0 does.

Is there something else i need to do in order to use 5.8.0?

3 Answers

You just have to add support for Java 8, place this inside the android block of your build.gradle

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

Let me know if it works

Go to application level gradle and write this

enter image description here

in app build.gradle

android{
 compileOptions {
 sourceCompatibility JavaVersion.VERSION_1_8
 targetCompatibility JavaVersion.VERSION_1_8
    }
  }
Related