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

僤鯓⒐⒋嵵緔 提交于 2019-12-01 06:19:46

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!