j256 / ormlite-android

ORMLite Android functionality used in conjunction with ormlite-core
http://ormlite.com/
ISC License
1.59k stars 367 forks source link

Annotation Processing not working in Android 2.3 #25

Closed guitcastro closed 9 years ago

guitcastro commented 10 years ago

I´m not familiar with your code and I don´t have enough knowledge to find out exactly it´s not working, but here is the case:

I tested the master branch on Android 4.4 an worked like a charm, but when testing using Android 2.3, I got a lot of errors in the annotated fields I debug the code in both devices (2.3 and 4.4) and notice that the difference was in the lookupClassesmethod in DatabaseTableConfigUtil, for some reason in Android 4.4 Class.forName("org.apache.harmony.lang.annotation.AnnotationFactory"); throws an exception and the method returns null.

I guess using apache AnnotationFactory it´s an attempt to optimize the annotations processing, but for some reason when this method is used in Android 2.3 (probably in others version as well) something goes wrong and the annotation process does not work, simple removing lookupClassesmethod was enough to fix the issue.

By annotation not working I mean get random errors like: "Field x has maxForeignAutoRefreshLevel set 2 but foreignAutoRefresh is false" in a primitive field annotated only with @DatabaseField

j256 commented 9 years ago

I think this is a dup of https://github.com/j256/ormlite-core/issues/26 I've fixed this in 4.49. I've removed the sanity check and added a way to turn off the annotation hack. Is anything else needed?