3

I have my stable app that's been working for months now, and after adding appcompat_v7 to support Material theme everything went to crap. I just changed my Activities to ActionBarActivity and the theme to Theme.AppCompat

Once every other run I get

java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation

inside a random library or in arbitrary points of execution not related to views. It requires a clean build and uninstall to get it to work 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:

Behaviour is erratic at best. It may or may not build and run correctly. My best guess is that appcompat_v7 doesn't like our config with multi-dex or having Gradle to not pre-dex libraries.

MLProgrammer-CiM
  • 17,231
  • 5
  • 42
  • 75
  • looking [here](http://stackoverflow.com/questions/11155340/java-lang-illegalaccesserror-class-ref-in-pre-verified-class-resolved-to-unexpe) it looks like you might have included something twice. You didn't add two appcompats or one appcompat jar as well as Appcompat android library did you? – FuegoFingers Oct 23 '14 at 20:02
  • No, and none of my Module dependencies brings it either. Maybe one of the UI libraries, but that shouldn't mean I have to provide it instead of compiling. If it does, Gradle still has a long way to go. – MLProgrammer-CiM Oct 23 '14 at 22:53
  • @MLProgrammer-CiM i see the answer below was updated today, did the new plugin resolve your issue? – AndroidEnthusiast Nov 04 '14 at 14:33
  • It did for me but not my coworkers :) – MLProgrammer-CiM Nov 04 '14 at 14:36
  • Can confirm that the multidex build system is still stochastic. We're reverting to a manual multidex.keep for the time being. – MLProgrammer-CiM Nov 04 '14 at 16:30

1 Answers1

2

You should include all your annotation classes in main dex.

The symptom is different, but the solution is the same as for this question:
How do you calculate which classes to put in your main-dex-list file?
There's a script that can generate it for you. I wrote a blogpost that shows how to use it.

Update (10/31/2014):
Gradle plugin v0.14.0 now does it automatically. See my answer here.

Community
  • 1
  • 1
Alex Lipov
  • 13,503
  • 5
  • 64
  • 87
  • 1
    Plugin 0.14.0 still has problems and we had to revert to the multidex.keep file approach. Google has documented that the build script is not smart enough to find classes that depend on library annotations or similar, so manual maintenance is still needed. – MLProgrammer-CiM Nov 05 '14 at 13:18