Java.lang.IllegalAccessError: ref class in pre-checked class resolved to unexpected implementation after adding AppCompat to stable application
I have a stable app that has been running for a few months now and after adding appcompat_v7 to support the stuff theme, things went to shit. I just changed my Activities to ActionBarActivity and theme to Theme.AppCompat
After every other launch, I get
java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
inside a random library or at arbitrary points of execution not associated with views. It requires a clean build and uninstallation to get it working again.
java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
at java.lang.reflect.Field.getAnnotation(Native Method)
at java.lang.reflect.Field.getAnnotation(Field.java:212)
at com.j256.ormlite.android.DatabaseTableConfigUtil.configFromField(DatabaseTableConfigUtil.java:243)
at com.j256.ormlite.android.DatabaseTableConfigUtil.fromClass(DatabaseTableConfigUtil.java:50)
at com.j256.ormlite.db.SqliteAndroidDatabaseType.extractDatabaseTableConfig(SqliteAndroidDatabaseType.java:76)
at com.j256.ormlite.dao.DaoManager.createDao(DaoManager.java:67)
at com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper.getDao(OrmLiteSqliteOpenHelper.java:279)
EDIT:
Behavior is erratic at best. It may or may not build and run correctly. Your best bet is to assume that appcompat_v7 doesn't like our multi-dex configuration, or has Gradle not pre-dex libraries.
source to share
You must include all of your annotation classes in the main file.
The symptom is different, but the solution is the same as for this question :
How do you figure out which classes to put in your file-dex-list?
There's a script that can generate it for you. I wrote a blogpost showing how to use it.
Update (10/31/2014) :
Gradle plugin v0.14.0 now does this automatically. See my answer here .
source to share