Greendao and proguard

2,448 views
Skip to first unread message

Lukasz Piliszczuk

unread,
Apr 13, 2012, 10:06:17 AM4/13/12
to gree...@googlegroups.com
Hello,

I'm trying to build an application using greendao with proguard.
I have no problem during compilation but I have the following exception when I'm running the app :

Caused by: de.greenrobot.dao.DaoException: Could not init DAOConfig
at de.greenrobot.dao.DaoConfig.<init>(Unknown Source)
at de.greenrobot.dao.AbstractDaoMaster.registerDaoClass(Unknown Source)
at com.siu.android.saintmande.d.<init>(Unknown Source)
at com.siu.android.saintmande.b.a.b(Unknown Source)
at com.siu.android.saintmande.e.b.doInBackground(Unknown Source)
at android.os.AsyncTask$2.call(AsyncTask.java:185)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
... 4 more
Caused by: java.lang.NoSuchFieldException: TABLENAME
at java.lang.ClassCache.findFieldByName(ClassCache.java:510)
at java.lang.Class.getField(Class.java:905)
... 11 more

I've tried to add something like this in the proguard.cfg :

-keep public class de.greenrobot.dao
-keep public class de.greenrobot.dao.** {
  public protected private *;
}

But still the same error.

Any idea ?
Thanks.



Markus Junginger

unread,
Apr 13, 2012, 10:15:39 AM4/13/12
to gree...@googlegroups.com
It should be sufficient to keep the following members of your (generated) DAO classes:
  • static field TABLENAME
  • Inner class Properties

Lukasz Piliszczuk

unread,
Apr 17, 2012, 1:55:02 PM4/17/12
to gree...@googlegroups.com
I could not make it work with only the two statements, but the following works :

-keep public class my.dao.package.models.** {
     public static <fields>;
}

Maybe you should reference the proguard config in the documentation ?
For people not expert in proguard like me.

Thanks for the help.

Markus Junginger

unread,
Apr 18, 2012, 10:44:59 AM4/18/12
to gree...@googlegroups.com
Thanks! I put it in the FAQ for now.

awefawef

unread,
Feb 26, 2013, 1:11:26 PM2/26/13
to gree...@googlegroups.com
Works for me

Ruben Parma

unread,
Apr 4, 2013, 12:43:37 PM4/4/13
to gree...@googlegroups.com
Hi, in the FAQ the <fields> part is missing because you put "<" and ">" on the html. You should use &lt;fields&gt; for it to be displayed correctly.

jimmy chen

unread,
Sep 23, 2014, 5:06:54 AM9/23/14
to gree...@googlegroups.com
works for me

inhaxio

unread,
Oct 31, 2014, 12:36:00 AM10/31/14
to gree...@googlegroups.com
Thanks, i was put it in proguard file and it work, imagine!

Irshad Chohan

unread,
Feb 5, 2015, 5:51:40 AM2/5/15
to gree...@googlegroups.com
I have made following scripts, which works for me.

-keep class my.dao.package.*$Properties {
    public static <fields>;
}

-keepclassmembers class my.dao.package.** {
    public static final <fields>;
Reply all
Reply to author
Forward
0 new messages