New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RealmUser is not part of the schema for this Realm #2162

Closed
itrufeng opened this Issue Jan 26, 2016 · 8 comments

Comments

Projects
None yet
5 participants
@itrufeng

I use kotlin
but always error.
My ProGuard here

-keep class io.realm.annotations.RealmModule
-keep @io.realm.annotations.RealmModule class *
-keep class io.realm.internal.Keep
-keep @io.realm.internal.Keep class * { *; }
-dontwarn javax.**
-dontwarn io.realm.**

My Exception here.

01-26 23:14:49.942 13155-13155/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                   Process: com.thoughtworks.jizhang.realmdemo, PID: 13155
                                                   java.lang.RuntimeException: Unable to start activity ComponentInfo{com.thoughtworks.jizhang.realmdemo/com.thoughtworks.jizhang.realmdemo.MainActivity}: java.lang.IllegalArgumentException: RealmUser is not part of the schema for this Realm
                                                       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2359)
                                                       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2422)
                                                       at android.app.ActivityThread.access$800(ActivityThread.java:159)
                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1319)
                                                       at android.os.Handler.dispatchMessage(Handler.java:102)
                                                       at android.os.Looper.loop(Looper.java:135)
                                                       at android.app.ActivityThread.main(ActivityThread.java:5313)
                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                       at java.lang.reflect.Method.invoke(Method.java:372)
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1116)
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:809)
                                                    Caused by: java.lang.IllegalArgumentException: RealmUser is not part of the schema for this Realm
                                                       at io.realm.internal.modules.CompositeMediator.getMediator(CompositeMediator.java:122)
                                                       at io.realm.internal.modules.CompositeMediator.getTableName(CompositeMediator.java:79)
                                                       at io.realm.Realm.getTable(Realm.java:1274)
                                                       at io.realm.Realm.createObject(Realm.java:660)
                                                       at com.thoughtworks.jizhang.realmdemo.MainActivity$setupSaveButton$1.invoke(MainActivity.kt:96)
                                                       at com.thoughtworks.jizhang.realmdemo.MainActivity.setupSaveButton(MainActivity.kt:136)
                                                       at com.thoughtworks.jizhang.realmdemo.MainActivity.setup(MainActivity.kt:40)
                                                       at com.thoughtworks.jizhang.realmdemo.MainActivity.onCreate(MainActivity.kt:34)
                                                       at android.app.Activity.performCreate(Activity.java:6036)
                                                       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
                                                       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2302)
                                                       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2422) 
                                                       at android.app.ActivityThread.access$800(ActivityThread.java:159) 
                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1319) 
                                                       at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                       at android.os.Looper.loop(Looper.java:135) 
                                                       at android.app.ActivityThread.main(ActivityThread.java:5313) 
                                                       at java.lang.reflect.Method.invoke(Native Method) 
                                                       at java.lang.reflect.Method.invoke(Method.java:372) 
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1116) 
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:809) 
@cmelchior

This comment has been minimized.

Show comment
Hide comment
@cmelchior

cmelchior Jan 27, 2016

Contributor

How does your RealmUser class look like?

Contributor

cmelchior commented Jan 27, 2016

How does your RealmUser class look like?

@itrufeng

This comment has been minimized.

Show comment
Hide comment
@itrufeng

itrufeng Jan 27, 2016

@cmelchior
like this.

public open class RealmUser: RealmObject() {
    public open var username: String? = null
    public open var age: Int? = null
}

@cmelchior
like this.

public open class RealmUser: RealmObject() {
    public open var username: String? = null
    public open var age: Int? = null
}
@cmelchior

This comment has been minimized.

Show comment
Hide comment
@cmelchior

cmelchior Jan 27, 2016

Contributor

That looks fine. It sounds like the annotation processor isn't running for some reason.

  1. Check the Gradle log. It should output something like "Note: Processing RealmUser". If that is not the case, our annotation processor isn't running.

  2. How did you add Realm to the project? You can see a working sample here: https://github.com/realm/realm-java/blob/master/examples/kotlinExample/build.gradle

Contributor

cmelchior commented Jan 27, 2016

That looks fine. It sounds like the annotation processor isn't running for some reason.

  1. Check the Gradle log. It should output something like "Note: Processing RealmUser". If that is not the case, our annotation processor isn't running.

  2. How did you add Realm to the project? You can see a working sample here: https://github.com/realm/realm-java/blob/master/examples/kotlinExample/build.gradle

@itrufeng

This comment has been minimized.

Show comment
Hide comment
@itrufeng

itrufeng Jan 29, 2016

@cmelchior
Thanks for you answer,
My code here, just a simple demo. there are all file, contain gradle file.
https://github.com/itrufeng/RealmDemo.

@cmelchior
Thanks for you answer,
My code here, just a simple demo. there are all file, contain gradle file.
https://github.com/itrufeng/RealmDemo.

@cmelchior

This comment has been minimized.

Show comment
Hide comment
@cmelchior

cmelchior Jan 29, 2016

Contributor

Hi @itrufeng
Your app/build.gradle file looks a bit wrong as you include both the Realm Jar and AAR. Try to change it to:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" // Kotlin
    compile 'io.reactivex:rxkotlin:0.30.1' // Rx for Kotlin
    compile 'com.jakewharton.rxbinding:rxbinding-kotlin:0.3.0' // Rx for UI Widget
    compile 'com.joanzapata.android:base-adapter-helper:1.1.11' // Adapter for View
//    compile 'io.reactivex:rxjava:1.0.10' // Realm Dependent
    compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
    compile "io.realm:realm-android-library:0.87.4@aar"
    compile "io.realm:realm-annotations:0.87.4"
    kapt "io.realm:realm-annotations:0.87.4"
    kapt "io.realm:realm-annotations-processor:0.87.4"
}
Contributor

cmelchior commented Jan 29, 2016

Hi @itrufeng
Your app/build.gradle file looks a bit wrong as you include both the Realm Jar and AAR. Try to change it to:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" // Kotlin
    compile 'io.reactivex:rxkotlin:0.30.1' // Rx for Kotlin
    compile 'com.jakewharton.rxbinding:rxbinding-kotlin:0.3.0' // Rx for UI Widget
    compile 'com.joanzapata.android:base-adapter-helper:1.1.11' // Adapter for View
//    compile 'io.reactivex:rxjava:1.0.10' // Realm Dependent
    compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
    compile "io.realm:realm-android-library:0.87.4@aar"
    compile "io.realm:realm-annotations:0.87.4"
    kapt "io.realm:realm-annotations:0.87.4"
    kapt "io.realm:realm-annotations-processor:0.87.4"
}
@itrufeng

This comment has been minimized.

Show comment
Hide comment
@itrufeng

itrufeng Jan 29, 2016

@cmelchior
It works.
Thank you very much.
👍

@cmelchior
It works.
Thank you very much.
👍

@itrufeng itrufeng closed this Jan 29, 2016

@timanglade timanglade removed the Pending label Jan 29, 2016

@Vaishnavi-optisol

This comment has been minimized.

Show comment
Hide comment
@Vaishnavi-optisol

Vaishnavi-optisol Jul 28, 2018

I tried all possible options. I'm using Kotlin with Dagger and Realm i'm getting same error still.

I tried all possible options. I'm using Kotlin with Dagger and Realm i'm getting same error still.

@Zhuinden

This comment has been minimized.

Show comment
Hide comment
@Zhuinden

Zhuinden Jul 28, 2018

Contributor

Did you apply Kotlin-kapt?

Contributor

Zhuinden commented Jul 28, 2018

Did you apply Kotlin-kapt?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment