Could not find the generated RealmProxy class: Annotation processor may not have been executed .

330 views
Skip to first unread message

Ranjth Yadav A.S

unread,
Dec 2, 2014, 8:48:54 AM12/2/14
to realm...@googlegroups.com
Hi,

When I am trying to create new instance of Realm using 
  Realm realm = Realm.getInstance(this); 
app is getting crashed.

Please check the following crash log,

12-02 19:10:15.716: E/AndroidRuntime(9035): FATAL EXCEPTION: main
12-02 19:10:15.716: E/AndroidRuntime(9035): Process: com.example.realmuserexample, PID: 9035
12-02 19:10:15.716: E/AndroidRuntime(9035): java.lang.RuntimeException: Unable to resume activity {com.example.realmuserexample/com.example.realmuserexample.RealmUserMainActivity}: io.realm.exceptions.RealmException: Could not find the generated io.realm.IngradientRealmProxy class: Annotation processor may not have been executed.
12-02 19:10:15.716: E/AndroidRuntime(9035): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3075)
12-02 19:10:15.716: E/AndroidRuntime(9035): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3104)
12-02 19:10:15.716: E/AndroidRuntime(9035): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2475)
12-02 19:10:15.716: E/AndroidRuntime(9035): at android.app.ActivityThread.access$900(ActivityThread.java:174)
12-02 19:10:15.716: E/AndroidRuntime(9035): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1307)
12-02 19:10:15.716: E/AndroidRuntime(9035): at android.os.Handler.dispatchMessage(Handler.java:102)
12-02 19:10:15.716: E/AndroidRuntime(9035): at android.os.Looper.loop(Looper.java:146)
12-02 19:10:15.716: E/AndroidRuntime(9035): at android.app.ActivityThread.main(ActivityThread.java:5593)
12-02 19:10:15.716: E/AndroidRuntime(9035): at java.lang.reflect.Method.invokeNative(Native Method)
12-02 19:10:15.716: E/AndroidRuntime(9035): at java.lang.reflect.Method.invoke(Method.java:515)
12-02 19:10:15.716: E/AndroidRuntime(9035): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
12-02 19:10:15.716: E/AndroidRuntime(9035): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
12-02 19:10:15.716: E/AndroidRuntime(9035): at dalvik.system.NativeStart.main(Native Method)
12-02 19:10:15.716: E/AndroidRuntime(9035): Caused by: io.realm.exceptions.RealmException: Could not find the generated io.realm.IngradientRealmProxy class: Annotation processor may not have been executed.
12-02 19:10:15.716: E/AndroidRuntime(9035): at io.realm.Realm.createAndValidate(Realm.java:417)
12-02 19:10:15.716: E/AndroidRuntime(9035): at io.realm.Realm.create(Realm.java:363)
12-02 19:10:15.716: E/AndroidRuntime(9035): at io.realm.Realm.getInstance(Realm.java:322)
12-02 19:10:15.716: E/AndroidRuntime(9035): at io.realm.Realm.getInstance(Realm.java:201)
12-02 19:10:15.716: E/AndroidRuntime(9035): at com.example.realmuserexample.RealmUserMainActivity.setupIngradient(RealmUserMainActivity.java:45)
12-02 19:10:15.716: E/AndroidRuntime(9035): at com.example.realmuserexample.RealmUserMainActivity.onResume(RealmUserMainActivity.java:40)
12-02 19:10:15.716: E/AndroidRuntime(9035): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1198)
12-02 19:10:15.716: E/AndroidRuntime(9035): at android.app.Activity.performResume(Activity.java:5537)
12-02 19:10:15.716: E/AndroidRuntime(9035): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3065)
12-02 19:10:15.716: E/AndroidRuntime(9035): ... 12 more


Following is my entity/model class,


import io.realm.RealmObject;
import io.realm.annotations.RealmClass;

@RealmClass
public class Ingradient extends RealmObject{
private int mIngradientId;
private String mIngradientName;
private String mQuantity;
public int getIngradientId() {
return mIngradientId;
}
public String getIngradientName() {
return mIngradientName;
}
public void setIngradientId(int mIngradientId) {
this.mIngradientId = mIngradientId;
}
public void setIngradientName(String mIngradientName) {
this.mIngradientName = mIngradientName;
}
public String getQuantity() {
return mQuantity;
}
public void setQuantity(String mQuantity) {
this.mQuantity = mQuantity;
}
}

I am using Eclipse Luna with JDK 1.7 and followed the latest documentation to add annotation processing in eclipse.
Still it not working with above entity class.But works fine with a model class (User) that you  mentioned in documentation.

Please suggest a way around.

Thanks & Regards,
Ranjith 





Emanuele Zattin

unread,
Dec 2, 2014, 8:55:00 AM12/2/14
to Ranjth Yadav A.s, realm...@googlegroups.com
Hello Ranijht,

did you let Eclipse generate the getters and setter or did you write them?

Android Studio follows the following convention:

fieldname: mName
getter: getmName
setter: setmName

your getters and setters don't have the "m" which is most likely the root cause of the problem. Does this help?

--
Emanuele Zattin



--
You received this message because you are subscribed to the Google Groups "Realm Java" group.
To unsubscribe from this group and stop receiving emails from it, send an email to realm-java+...@googlegroups.com.
To post to this group, send email to realm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/realm-java/e6fa06f7-e0d2-4681-9e4a-89a2c4e608a2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



{#HS:58174992-101#}

Ranjth Yadav A.S

unread,
Dec 2, 2014, 10:37:41 PM12/2/14
to realm...@googlegroups.com
Hello Emanuele,

Thanks. As you mentioned the root causes for the problem were field names in  getters and setters.
Now it works.

Regards,
Ranjith
Reply all
Reply to author
Forward
0 new messages