Realm for Android with Kotlin - Cannot change Dependencies of Configuration after it has been included in dependency resolution

后端 未结 1 413
悲哀的现实
悲哀的现实 2021-01-13 17:30

I am trying to get Realm to work in my project. I have Kotlin with version 1.2.51 and Instant Run disabled.

In my project build.gradle file I added the

1条回答
  •  北海茫月
    2021-01-13 17:55

    Seems to be a bug in the Realm-Transformer 5.4.0, which happens only if experimental = true is enabled for Kotlin Android Extensions.

    EDIT: Using 5.4.1+ should solve this problem.


    PREVIOUS ANSWER: You can use manually defined versions in the build.gradle file in the meantime:

     buildscript {
        ext.kotlin_version = '1.2.51'
        ext.realm_version = '5.4.0'
    
        repositories {
            jcenter()
            mavenCentral()
        }
    
       dependencies {
           classpath "io.realm:realm-transformer:5.1.0"
           classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
       }
     }
    
     apply plugin: 'com.android.application'
     apply plugin: 'kotlin-android'
     apply plugin: 'kotlin-kapt'
    
     import io.realm.transformer.RealmTransformer
     android.registerTransform(new RealmTransformer(project))
    
     dependencies {
       implementation "io.realm:realm-annotations:$realm_version"
       implementation "io.realm:realm-android-library:$realm_version"
       implementation "io.realm:realm-android-kotlin-extensions:$realm_version" {
           exclude group: "org.jetbrains.kotlin", module: "kotlin-stdlib-jdk7"
       }
       kapt "io.realm:realm-annotations-processor:$realm_version"
     }
    

    As per docs.

    0 讨论(0)
提交回复
热议问题