jsondb-core
jsondb-core copied to clipboard
No class found with @Document Annotation and attribute collectionName as: User, Android
Hello there, when I try to create collection this exception is thrown " No class found with @Document Annotation and attribute collection Name as: User ", I am sure 100% my code and implementation are correct. If I use it in java code test it work 100%. The problem in reflection does not find the classes at runtime (samsung device). check the code below please:
this is my db init code:
String baseScanPackage = "com.myapp.chat.model";
String base64EncodedKey = CryptoUtil.generate128BitKey(SomeSecretPassword, SomeUniqueSecreteSalt);
ICipher cipher = new Default1Cipher(base64EncodedKey);
jsonDBTemplate = new JsonDBTemplate(dbFilesLocation, baseScanPackage, cipher);
if (!jsonDBTemplate.collectionExists(User.class))
jsonDBTemplate.createCollection(User.class);
this is my User class code:
@Document(collection = "User", schemaVersion= "1.0")
public class User implements Serializable {
@Id
public String id;
public User() {
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}
the problem is in reflection does not find classes at runtime.
As you noticed in #42 there is currently No way to use this library on Android as the reflection lib is Not working. Currently the best way to Go is to use a working library targeting Android Like Realm, Objectbox, Room, etc
@Hatzen I appreciate your reply, big thanks for you. How other libraries work ?? which are using annotation, like Room for example your use @Entity , @Id .... , how did they used reflection or finding classes, Probably it is prebuild process or some thing like that is related to gradle?. actually I am low experience with gradle.