Build my android app with 'io.realm:realm-gradle-plugin:0.88.2' and android studio 3.1
Successful build with 'io.realm:realm-gradle-plugin:0.88.2' with android studio 3.1
android-apt plugin is incompatible with the Android Gradle plugin. Please use 'annotationProcessor' configuration instead.
Realm version(s): 0.88.2
Realm sync feature enabled: yes/no
Android Studio version: 3.1
Which Android version and device: Samsung Galaxy 7.x
Notes:
I can not upgrade to a newer version of realm-java. I need to do a successful build with 0.88.2. Can you please help me resolve above issue?
Hm, why not 0.88.3? That's more stable than 0.88.2.
Anyways, you can try
buildscript {
ext.realm_version = '0.88.3'
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath "io.realm:realm-transformer:$realm_version"
}
}
apply plugin: 'com.android.application'
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"
annotationProcessor "io.realm:realm-annotations-processor:$realm_version"
}
I cannot guarantee that it works though
Please pardon my ignorance. I get following error.
I see this if I add it to my build.gradle (I tried both top level and app level)
Could not find matching constructor for:
io.realm.transformer.RealmTransformer(org.gradle.api.internal.project.DefaultProject_Decorated)
Where do I need to add following two lines:
import io.realm.transformer.RealmTransformer
android.registerTransform(new RealmTransformer(project))
Is there any workaround like using aar/jar/so files directly. I have a previous build cached. Can I use that somehow?
You definitely need a version of Android Studio below 3.1. I believe annotationProcessor replaced apt in 2.2 or something, so you need an earlier version than that. The transformer code should be added in your app module build.gradle. You can see it here: https://realm.io/docs/java/latest/#how-do-i-customize-dependecies-defined-by-the-realm-gradle-plugin
You can reference Jars directly, but it is a bit convoluted and I don't have a guide at hand, so you will have to research it yourself. It is possible though as I made it work a year or so ago.
You could try to not pass project, that seems new: https://github.com/realm/realm-java/blob/560da0772e19db7133e9d8088db0a18c253461e3/realm-transformer/src/main/groovy/io/realm/transformer/RealmTransformer.groovy
@Zhuinden Thank you so much for response.
Gradle Sync finishes successfully.
I added in top level build.gradle
ext.realm_version = '0.88.2'
classpath "io.realm:realm-transformer:$realm_version"
I added in app level build.gradle
import io.realm.transformer.RealmTransformer
android.registerTransform(new RealmTransformer())
dependencies {
implementation "io.realm:realm-annotations:$realm_version"
implementation "io.realm:realm-android-library:$realm_version"
annotationProcessor "io.realm:realm-annotations-processor:$realm_version"
}
Most helpful comment
@Zhuinden Thank you so much for response.
Gradle Sync finishes successfully.
I added in top level build.gradle
I added in app level build.gradle