问题
I'm trying to set up an application that uses the Realm database but I can't seem to make it work. I've also disabled Instant Run but that didn't solve the problem either.
Here are my code files:
App level build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions' // <-- these two were the problem
apply plugin: 'kotlin-android' // <--
apply plugin: 'com.google.gms.google-services'
apply plugin: 'realm-android'
Project level build.gradle
dependencies{
classpath 'com.android.tools.build:gradle:3.3.0'
classpath 'com.google.gms:google-services:4.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'io.realm:realm-gradle-plugin:5.8.0'
}
One of my model classes
public class ClothingItem extends RealmObject{
private String mItemName;
private RealmList<String> mItemTags;
....
Application class where I initialize Realm
public void onCreate(){
super.oncreate();
Realm.init(this);
RealmConfiguration config = new RealmConfiguration.Builder()
.deleteRealmIfMigrationNeeded()
.name("MyOnlineWardrobe.realm")
.build();
Realm.setDefaultConfiguration(config);
}
回答1:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-kapt' // <---
apply plugin: 'realm-android'
来源:https://stackoverflow.com/questions/54558333/how-to-fix-object-is-not-part-of-the-schema-for-this-realm